pub trait ModifierNodeElement:
Sized
+ Debug
+ Hash
+ PartialEq
+ 'static {
type Node: ModifierNode;
const FROM_NODE: Option<fn(&Self::Node) -> Self> = None;
// Required methods
fn create(&self) -> Self::Node;
fn update(&self, node: &mut Self::Node);
// Provided methods
fn equals_node(&self, node: &Self::Node) -> bool { ... }
fn key(&self) -> Option<u64> { ... }
fn inspector_name(&self) -> &'static str { ... }
fn inspector_properties(
&self,
_inspector: &mut dyn FnMut(&'static str, String),
) { ... }
fn capabilities(&self) -> NodeCapabilities { ... }
fn always_update(&self) -> bool { ... }
fn auto_invalidate_on_update(&self) -> bool { ... }
fn update_invalidation_kind(&self) -> Option<InvalidationKind> { ... }
fn provided_composition_locals(&self) -> Vec<ProvidedValue> { ... }
}Expand description
Strongly typed modifier elements that can create and update nodes while exposing equality/hash/inspector contracts that mirror Jetpack Compose.
Provided Associated Constants§
Sourceconst FROM_NODE: Option<fn(&Self::Node) -> Self> = None
const FROM_NODE: Option<fn(&Self::Node) -> Self> = None
Makes the element again from a node it created or last updated, for
an element whose node keeps every value of it and that asks for no
update when equal. A chain keeps no such element beside its node: it
compares a new element with the node. None, the default, keeps the
element.
Required Associated Types§
Sourcetype Node: ModifierNode
type Node: ModifierNode
The type of node that the element creates and updates.
Required Methods§
Provided Methods§
Sourcefn equals_node(&self, node: &Self::Node) -> bool
fn equals_node(&self, node: &Self::Node) -> bool
Whether node keeps an element equal to this one, for an element
with Self::FROM_NODE. An element whose node holds values a copy
would count references of compares them in place.
Sourcefn key(&self) -> Option<u64>
fn key(&self) -> Option<u64>
Optional key used to disambiguate multiple instances of the same element type.
Sourcefn inspector_name(&self) -> &'static str
fn inspector_name(&self) -> &'static str
Human readable name surfaced to inspector tooling.
Sourcefn inspector_properties(&self, _inspector: &mut dyn FnMut(&'static str, String))
fn inspector_properties(&self, _inspector: &mut dyn FnMut(&'static str, String))
Records inspector properties for tooling.
Sourcefn capabilities(&self) -> NodeCapabilities
fn capabilities(&self) -> NodeCapabilities
Returns the capabilities of nodes created by this element. Override this to indicate which specialized traits the node implements.
Sourcefn always_update(&self) -> bool
fn always_update(&self) -> bool
Whether this element requires update to be called even if eq returns true.
This is useful for elements that ignore certain fields in eq (e.g. closures)
to allow node reuse, but still need those fields updated in the existing node.
Defaults to false.
Sourcefn auto_invalidate_on_update(&self) -> bool
fn auto_invalidate_on_update(&self) -> bool
Whether modifier reconciliation should request capability-wide invalidations after updating an existing node.
Sourcefn update_invalidation_kind(&self) -> Option<InvalidationKind>
fn update_invalidation_kind(&self) -> Option<InvalidationKind>
Optional targeted invalidation requested after updating an existing node.
This is for nodes whose attach/remove capability is broader than the work needed for a value-only update. For example, an offset node participates in layout on attach but an x/y change only needs placement data and draw output refreshed.
Sourcefn provided_composition_locals(&self) -> Vec<ProvidedValue>
fn provided_composition_locals(&self) -> Vec<ProvidedValue>
Composition locals this element hands to the content composed inside the node it decorates.
A modifier that stands for something its subtree lives in, the way a window does, passes that thing down here instead of asking every composable in between to carry it as an argument.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".