Trait Element

Source
pub trait Element:
    Debug
    + AsAny
    + 'static {
    // Provided method
    fn wrapped_element(&self) -> Option<&dyn Element> { ... }
}
Expand description

Marker trait for any type that will be used as a composition element.

Can be implemented via its derive macro:

#[derive(Element)]
pub struct CustomCompositionElement;

If implementing maually, remember to tag the impl block with #[typetag::serde] for proper serialization behavior.

Advanced: Overriding the default wrapped_element method indicates another element this one wraps. Wrapped elements will render alongside their wrappers, producing a cumulative set of children. Mainly used to provide a common ‘tag’ type for an unknown set of other elements, enabling context lookups or other operations that depend on element type.

Provided Methods§

Source

fn wrapped_element(&self) -> Option<&dyn Element>

None.

Implementors§