Skip to main content

ModifierNodeElement

Trait ModifierNodeElement 

Source
pub trait ModifierNodeElement:
    Debug
    + Hash
    + PartialEq
    + 'static {
    type Node: ModifierNode;

    // Required methods
    fn create(&self) -> Self::Node;
    fn update(&self, node: &mut Self::Node);

    // Provided methods
    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 { ... }
}
Expand description

Strongly typed modifier elements that can create and update nodes while exposing equality/hash/inspector contracts that mirror Jetpack Compose.

Required Associated Types§

Required Methods§

Source

fn create(&self) -> Self::Node

Creates a new modifier node instance for this element.

Source

fn update(&self, node: &mut Self::Node)

Brings an existing modifier node up to date with the element’s data.

Provided Methods§

Source

fn key(&self) -> Option<u64>

Optional key used to disambiguate multiple instances of the same element type.

Source

fn inspector_name(&self) -> &'static str

Human readable name surfaced to inspector tooling.

Source

fn inspector_properties(&self, _inspector: &mut dyn FnMut(&'static str, String))

Records inspector properties for tooling.

Source

fn capabilities(&self) -> NodeCapabilities

Returns the capabilities of nodes created by this element. Override this to indicate which specialized traits the node implements.

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§