Trait CustomEntitySerializer

Source
pub trait CustomEntitySerializer {
    type SerializedID: Serialize + for<'a> Deserialize<'a>;

    // Required methods
    fn to_serialized(&self, entity: Entity) -> Self::SerializedID;
    fn from_serialized(&self, serialized: Self::SerializedID) -> Entity;
}
Expand description

Describes a mapping between a runtime Entity ID and a serialized equivalent.

Implementing this trait will automatically implement EntitySerializer for the type.

Developers should be aware of their serialization/deserialization use-cases as well as world-merge use cases when picking a SerializedID, as this type must identify unique entities across world serialization/deserialization cycles as well as across world merges.

Required Associated Types§

Source

type SerializedID: Serialize + for<'a> Deserialize<'a>

The type used for serialized Entity IDs.

Required Methods§

Source

fn to_serialized(&self, entity: Entity) -> Self::SerializedID

Constructs the serializable representation of Entity

Source

fn from_serialized(&self, serialized: Self::SerializedID) -> Entity

Convert a SerializedEntity to an Entity.

Implementors§