[][src]Trait specs::saveload::MarkerAllocator

pub trait MarkerAllocator<M: Marker>: Resource {
    fn allocate(&mut self, entity: Entity, id: Option<M::Identifier>) -> M;
fn retrieve_entity_internal(&self, id: M::Identifier) -> Option<Entity>;
fn maintain(&mut self, _entities: &EntitiesRes, _storage: &ReadStorage<M>); fn retrieve_entity(
        &mut self,
        marker: M,
        storage: &mut WriteStorage<M>,
        entities: &EntitiesRes
    ) -> Entity { ... }
fn mark<'m>(
        &mut self,
        entity: Entity,
        storage: &'m mut WriteStorage<M>
    ) -> Option<(&'m M, bool)> { ... } }

This allocator is used with the Marker trait. It provides a method for allocating new Markers. It should also provide a Marker -> Entity mapping. The maintain method can be implemented for cleanup and actualization. See docs for Marker for an example.

Required methods

fn allocate(&mut self, entity: Entity, id: Option<M::Identifier>) -> M

Allocates a new marker for a given entity. If you don't pass an id, a new unique id will be created.

fn retrieve_entity_internal(&self, id: M::Identifier) -> Option<Entity>

Get an Entity by a marker identifier. This function only accepts an id; it does not update the marker data.

Implementors usually maintain a marker -> entity mapping and use that to retrieve the entity.

fn maintain(&mut self, _entities: &EntitiesRes, _storage: &ReadStorage<M>)

Maintain internal data. Cleanup if necessary.

Loading content...

Provided methods

fn retrieve_entity(
    &mut self,
    marker: M,
    storage: &mut WriteStorage<M>,
    entities: &EntitiesRes
) -> Entity

Tries to retrieve an entity by the id of the marker; if no entity has a marker with the same id, a new entity will be created and marker will be inserted for it.

In case the entity existed, this method will update the marker data using Marker::update.

fn mark<'m>(
    &mut self,
    entity: Entity,
    storage: &'m mut WriteStorage<M>
) -> Option<(&'m M, bool)>

Create new unique marker M and attach it to entity. Or get old marker if this entity is already marked. If entity is dead then this will return None.

Loading content...

Implementors

impl MarkerAllocator<UuidMarker> for UuidMarkerAllocator[src]

impl<T: ?Sized> MarkerAllocator<SimpleMarker<T>> for SimpleMarkerAllocator<T> where
    T: 'static + Send + Sync
[src]

Loading content...