lib.rs 1.5 KB

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