Trait Element

Source
pub trait Element:
    Debug
    + AsAny
    + 'static
    + Serialize
    + Deserialize {
    // Provided method
    fn wrapped_element(&self) -> Option<&(dyn Element + 'static)> { ... }
}
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 + 'static)>

None.

Trait Implementations§

Source§

impl<'typetag> Serialize for dyn Element + 'typetag

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Element + Send + 'typetag

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Element + Sync + Send + 'typetag

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'typetag> Serialize for dyn Element + Sync + 'typetag

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Implementors§