MapComponent

Trait MapComponent 

Source
pub trait MapComponent<T: Component>:
    'static
    + Clone
    + Send
    + Sync {
    type Output: Component;

    // Required method
    fn map_component(&self, component: &T) -> Self::Output;
}
Expand description

A trait used for mapping components during a save operation.

§Usage

Component mapping is useful when you wish to serialize an unserializable component.

All component mappers are executed BEFORE the serialization step of the Save Pipeline. When invoked, the given component T will be replaced with the output of the mapper for all saved entities. When the save operation is complete, the original component will be restored.

Keep in mind that this will trigger change detection for the mapped component.

Required Associated Types§

Source

type Output: Component

The mapped output type.

Required Methods§

Source

fn map_component(&self, component: &T) -> Self::Output

Called during the Save/Load process to map components.

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§

Source§

impl<F, T: Component, U: Component> MapComponent<T> for F
where F: 'static + Clone + Send + Sync + Fn(&T) -> U,