document state trait

This commit is contained in:
Evan Almloff committed 2023-02-11 17:43:08 -06:00
1 parent d8da8e4275
commit fe3ad8ebe9
11 files changed
+58 -55

No files matched your search

+9 -6
View File
@@ -103,16 +103,18 @@ impl DirtyNodeStates {
}
}
pub trait Pass<V: FromAnyValue + Send + Sync = ()>: Any + Send + Sync {
/// This is a tuple of (T: Any, ..)
pub trait State<V: FromAnyValue + Send + Sync = ()>: Any + Send + Sync {
/// This is a tuple of (T: Pass, ..) of states read from the parent required to run this pass
type ParentDependencies: Dependancy;
/// This is a tuple of (T: Any, ..)
/// This is a tuple of (T: Pass, ..) of states read from the children required to run this pass
type ChildDependencies: Dependancy;
/// This is a tuple of (T: Any, ..)
/// This is a tuple of (T: Pass, ..) of states read from the node required to run this pass
type NodeDependencies: Dependancy;
/// This is a mask of what aspects of the node are required to run this pass
const NODE_MASK: NodeMaskBuilder<'static>;
fn pass<'a>(
/// Update this state in a node, returns if the state was updated
fn update<'a>(
&mut self,
node_view: NodeView<V>,
node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
@@ -121,6 +123,7 @@ pub trait Pass<V: FromAnyValue + Send + Sync = ()>: Any + Send + Sync {
context: &SendAnyMap,
) -> bool;
/// Create a new instance of this state
fn create<'a>(
node_view: NodeView<V>,
node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
@@ -202,7 +205,7 @@ pub trait Pass<V: FromAnyValue + Send + Sync = ()>: Any + Send + Sync {
.value
.as_mut()
.unwrap()
.pass(view, node, parent, children, context)
.update(view, node, parent, children, context)
}
},
) as PassCallback,