Function legion::serialize::set_entity_serializer
source · [−]pub fn set_entity_serializer<F, R>(
entity_serializer: &dyn EntitySerializer,
func: F
) -> R where
F: FnOnce() -> R,
Expand description
Sets the EntitySerializer
currently being used to serialize or deserialize Entity
IDs.
This is set automatically when serializing or deserializing a [World
]. When serializing or
deserializing values outside a World
, this needs to be set manually, passing in a reference
to the EntitySerializer
and a closure that does the serializing/deserializing.
let entity_serializer = Canon::default();
set_entity_serializer(&entity_serializer, || {
serde_json::to_value(contains_entity).unwrap()
});