[−][src]Struct legion::Registry
A world (de)serializer which describes how to (de)serialize the component types in a world.
The type parameter T
represents the key used in the serialized output to identify each
component type. The type keys used must uniquely identify each component type, and be stable
between recompiles.
See the legion_typeuuid crate for an example of a type key which is stable between compiles.
Implementations
impl<T, S> Registry<T, S> where
T: TypeKey,
S: CustomEntitySerializer + 'static,
[src]
T: TypeKey,
S: CustomEntitySerializer + 'static,
pub fn new(entity_serializer: S) -> Self
[src]
Constructs a new registry.
pub fn on_unknown(&mut self, unknown: UnknownType)
[src]
Sets the behavior to use when a component type is unknown.
pub fn register<C: Component + Serialize + for<'de> Deserialize<'de>>(
&mut self,
mapped_type_id: T
)
[src]
&mut self,
mapped_type_id: T
)
Registers a component type and its key with the registry.
pub fn register_auto_mapped<C: Component + Serialize + for<'de> Deserialize<'de>>(
&mut self
) where
T: AutoTypeKey<C>,
[src]
&mut self
) where
T: AutoTypeKey<C>,
Registers a component type and its key with the registry.
pub fn as_deserialize_into_world<'a>(
&'a self,
world: &'a mut World
) -> DeserializeIntoWorld<'a, Self>
[src]
&'a self,
world: &'a mut World
) -> DeserializeIntoWorld<'a, Self>
Constructs a serde::DeserializeSeed which will deserialize into an existing world.
pub fn as_deserialize(&self) -> DeserializeNewWorld<'_, Self>
[src]
Constructs a serde::DeserializeSeed which will deserialize into a new world.
Trait Implementations
impl<T, S> Default for Registry<T, S> where
T: TypeKey,
S: CustomEntitySerializer + Default + 'static,
[src]
T: TypeKey,
S: CustomEntitySerializer + Default + 'static,
impl<T, S> WorldDeserializer for Registry<T, S> where
T: TypeKey,
S: CustomEntitySerializer + 'static,
[src]
T: TypeKey,
S: CustomEntitySerializer + 'static,
type TypeId = T
The stable type ID used to identify each component type in the serialized data.
fn unmap_id(
&self,
type_id: &Self::TypeId
) -> Result<ComponentTypeId, UnknownType>
[src]
&self,
type_id: &Self::TypeId
) -> Result<ComponentTypeId, UnknownType>
fn register_component(&self, type_id: Self::TypeId, layout: &mut EntityLayout)
[src]
fn deserialize_component_slice<'a, 'de, D: Deserializer<'de>>(
&self,
type_id: ComponentTypeId,
storage: UnknownComponentWriter<'a>,
deserializer: D
) -> Result<(), D::Error>
[src]
&self,
type_id: ComponentTypeId,
storage: UnknownComponentWriter<'a>,
deserializer: D
) -> Result<(), D::Error>
fn deserialize_component<'de, D: Deserializer<'de>>(
&self,
type_id: ComponentTypeId,
deserializer: D
) -> Result<Box<[u8]>, D::Error>
[src]
&self,
type_id: ComponentTypeId,
deserializer: D
) -> Result<Box<[u8]>, D::Error>
fn with_entity_serializer(
&self,
callback: &mut dyn FnMut(&dyn EntitySerializer)
)
[src]
&self,
callback: &mut dyn FnMut(&dyn EntitySerializer)
)
impl<T, S> WorldSerializer for Registry<T, S> where
T: TypeKey,
S: CustomEntitySerializer + 'static,
[src]
T: TypeKey,
S: CustomEntitySerializer + 'static,
type TypeId = T
The stable type ID used to identify each component type in the serialized data.
unsafe fn serialize_component<Ser: Serializer>(
&self,
ty: ComponentTypeId,
ptr: *const u8,
serializer: Ser
) -> Result<Ser::Ok, Ser::Error>
[src]
&self,
ty: ComponentTypeId,
ptr: *const u8,
serializer: Ser
) -> Result<Ser::Ok, Ser::Error>
fn map_id(&self, type_id: ComponentTypeId) -> Result<Self::TypeId, UnknownType>
[src]
unsafe fn serialize_component_slice<Ser: Serializer>(
&self,
ty: ComponentTypeId,
storage: &dyn UnknownComponentStorage,
archetype: ArchetypeIndex,
serializer: Ser
) -> Result<Ser::Ok, Ser::Error>
[src]
&self,
ty: ComponentTypeId,
storage: &dyn UnknownComponentStorage,
archetype: ArchetypeIndex,
serializer: Ser
) -> Result<Ser::Ok, Ser::Error>
fn with_entity_serializer(
&self,
callback: &mut dyn FnMut(&dyn EntitySerializer)
)
[src]
&self,
callback: &mut dyn FnMut(&dyn EntitySerializer)
)
Auto Trait Implementations
impl<T, S = Canon> !RefUnwindSafe for Registry<T, S>
impl<T, S> Send for Registry<T, S> where
S: Send,
T: Send,
S: Send,
T: Send,
impl<T, S> Sync for Registry<T, S> where
S: Send + Sync,
T: Sync,
S: Send + Sync,
T: Sync,
impl<T, S> Unpin for Registry<T, S> where
S: Unpin,
T: Unpin,
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for Registry<T, S> where
S: UnwindSafe,
T: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,