pub struct LoadedEntity<S: LeafStore> {
pub store: S,
pub link: ExactLink,
pub entity: Entity,
pub digest: Digest,
pub pending_components: Vec<ComponentKind>,
}
Fields§
§store: S
§link: ExactLink
§entity: Entity
§digest: Digest
The digest of the entity. This may be a null digest if you have just called
get_or_init()
, and the digest has not computed yet.
It will also not be updated until save()
is called when making
changes to the entity.
pending_components: Vec<ComponentKind>
The list of components that have been added to the entity, but haven’t been written to storage yet.
Implementations§
Source§impl<S: LeafStore> LoadedEntity<S>
impl<S: LeafStore> LoadedEntity<S>
Sourcepub fn del_components<C: Component>(&mut self)
pub fn del_components<C: Component>(&mut self)
Delete all components of the given type.
The changes will not be persisted until save()
is called.
pub fn del_components_by_schema(&mut self, schema: Digest)
Sourcepub async fn get_component<C: Component>(&self) -> Result<Option<C>>
pub async fn get_component<C: Component>(&self) -> Result<Option<C>>
Get the first component of a given type on the entity, or None
if there is no component
of that type.
Sourcepub async fn get_components<C: Component>(&self) -> Result<Vec<C>>
pub async fn get_components<C: Component>(&self) -> Result<Vec<C>>
Get all components of the given type on the entity.
pub async fn get_components_by_schema( &self, schema: Digest, ) -> Result<Vec<Vec<u8>>>
Sourcepub fn set_component<C: Component>(&mut self, data: C) -> Result<()>
pub fn set_component<C: Component>(&mut self, data: C) -> Result<()>
Remove all components of the same type that are already on the entity, and then add the component to the entity.
This is similar to add_component()
, but it makes sure that after
it’s done there is only one component of the given type on the entity.
The change will not be persisted until save()
is called.
Sourcepub fn add_component<C: Component>(&mut self, data: C) -> Result<()>
pub fn add_component<C: Component>(&mut self, data: C) -> Result<()>
Add a component to the entity.
The component will not be persisted until save()
is called.