lib.rs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #![doc = include_str!("../README.md")]
  2. pub mod prelude {
  3. pub use crate::*;
  4. }
  5. mod root;
  6. pub use atoms::*;
  7. pub use hooks::*;
  8. pub use root::*;
  9. mod atoms {
  10. mod atom;
  11. mod atomfamily;
  12. mod atomref;
  13. mod selector;
  14. mod selectorfamily;
  15. pub use atom::*;
  16. pub use atomfamily::*;
  17. pub use atomref::*;
  18. pub use selector::*;
  19. pub use selectorfamily::*;
  20. }
  21. pub mod hooks {
  22. mod atom_ref;
  23. mod atom_root;
  24. mod init_atom_root;
  25. mod read;
  26. mod set;
  27. mod state;
  28. pub use atom_ref::*;
  29. pub use atom_root::*;
  30. pub use init_atom_root::*;
  31. pub use read::*;
  32. pub use set::*;
  33. pub use state::*;
  34. }
  35. /// All Atoms are `Readable` - they support reading their value.
  36. ///
  37. /// This trait lets Dioxus abstract over Atoms, AtomFamilies, AtomRefs, and Selectors.
  38. /// It is not very useful for your own code, but could be used to build new Atom primitives.
  39. pub trait Readable<V> {
  40. fn read(&self, root: AtomRoot) -> Option<V>;
  41. fn init(&self) -> V;
  42. fn unique_id(&self) -> AtomId;
  43. }
  44. /// All Atoms are `Writable` - they support writing their value.
  45. ///
  46. /// This trait lets Dioxus abstract over Atoms, AtomFamilies, AtomRefs, and Selectors.
  47. /// This trait lets Dioxus abstract over Atoms, AtomFamilies, AtomRefs, and Selectors
  48. pub trait Writable<V>: Readable<V> {
  49. fn write(&self, root: AtomRoot, value: V);
  50. }