Trait WorldSerializer

Source
pub trait WorldSerializer {
    type TypeId: Serialize + Ord;

    // Required methods
    fn map_id(
        &self,
        type_id: ComponentTypeId,
    ) -> Result<Self::TypeId, UnknownType>;
    unsafe fn serialize_component<S>(
        &self,
        ty: ComponentTypeId,
        ptr: *const u8,
        serializer: S,
    ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
       where S: Serializer;
    unsafe fn serialize_component_slice<S>(
        &self,
        ty: ComponentTypeId,
        storage: &(dyn UnknownComponentStorage + 'static),
        archetype: ArchetypeIndex,
        serializer: S,
    ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
       where S: Serializer;
}
Expand description

Describes a type which knows how to deserialize the components in a world.

Required Associated Types§

Source

type TypeId: Serialize + Ord

The stable type ID used to identify each component type in the serialized data.

Required Methods§

Source

fn map_id(&self, type_id: ComponentTypeId) -> Result<Self::TypeId, UnknownType>

Converts a runtime component type ID into the serialized type ID.

Source

unsafe fn serialize_component<S>( &self, ty: ComponentTypeId, ptr: *const u8, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serializes a single component.

§Safety

The pointer must point to a valid instance of the component type represented by the given component type ID.

Source

unsafe fn serialize_component_slice<S>( &self, ty: ComponentTypeId, storage: &(dyn UnknownComponentStorage + 'static), archetype: ArchetypeIndex, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serializes a slice of components.

§Safety

The pointer must point to a valid instance of the component type represented by the given component type ID.

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<T> WorldSerializer for Registry<T>
where T: TypeKey,