pub trait SerializeComponents<E, M>where
M: Marker,{
type Data: Serialize;
// Required method
fn serialize_entity<F>(
&self,
entity: Entity,
ids: F,
) -> Result<Self::Data, E>
where F: FnMut(Entity) -> Option<M>;
// Provided methods
fn serialize<S>(
&self,
entities: &EntitiesRes,
markers: &ReadStorage<'_, M>,
serializer: S,
) -> Result<S::Ok, S::Error>
where E: Display,
S: Serializer { ... }
fn serialize_recursive<S>(
&self,
entities: &EntitiesRes,
markers: &mut WriteStorage<'_, M>,
allocator: &mut M::Allocator,
serializer: S,
) -> Result<S::Ok, S::Error>
where E: Display,
M: Marker,
S: Serializer { ... }
}
Expand description
A trait which allows to serialize entities and their components.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn serialize<S>(
&self,
entities: &EntitiesRes,
markers: &ReadStorage<'_, M>,
serializer: S,
) -> Result<S::Ok, S::Error>where
E: Display,
S: Serializer,
fn serialize<S>(
&self,
entities: &EntitiesRes,
markers: &ReadStorage<'_, M>,
serializer: S,
) -> Result<S::Ok, S::Error>where
E: Display,
S: Serializer,
Serialize components from specified storages
of all marked entities with provided serializer.
When the component gets serialized the closure passed
in ids
argument returns None
for unmarked Entity
.
In this case serialization of this component may perform workaround or
fail. So the function doesn’t recursively mark referenced entities.
For recursive marking see serialize_recursive
Sourcefn serialize_recursive<S>(
&self,
entities: &EntitiesRes,
markers: &mut WriteStorage<'_, M>,
allocator: &mut M::Allocator,
serializer: S,
) -> Result<S::Ok, S::Error>
fn serialize_recursive<S>( &self, entities: &EntitiesRes, markers: &mut WriteStorage<'_, M>, allocator: &mut M::Allocator, serializer: S, ) -> Result<S::Ok, S::Error>
Serialize components from specified storages
of all marked entities with provided serializer.
When the component gets serialized the closure passed
in ids
argument marks unmarked Entity
(the marker of which was
requested) and it will get serialized recursively.
For serializing without such recursion see serialize
function.
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.