fermi/
lib.rs

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