Trait legion::serialize::CustomEntitySerializer
source · [−]pub trait CustomEntitySerializer {
type SerializedID: Serialize + for<'a> Deserialize<'a>;
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.
Associated Types
type SerializedID: Serialize + for<'a> Deserialize<'a>
type SerializedID: Serialize + for<'a> Deserialize<'a>
The type used for serialized Entity IDs.
Required methods
fn to_serialized(&self, entity: Entity) -> Self::SerializedID
fn to_serialized(&self, entity: Entity) -> Self::SerializedID
Constructs the serializable representation of Entity
fn from_serialized(&self, serialized: Self::SerializedID) -> Entity
fn from_serialized(&self, serialized: Self::SerializedID) -> Entity
Convert a SerializedEntity
to an Entity
.