pub struct Store { /* private fields */ }
Expand description
A karmeliet triple store.
Implementations§
Source§impl Store
impl Store
Sourcepub fn insert<T: 'static>(&mut self, e: Entity, value: T) -> Option<T>
pub fn insert<T: 'static>(&mut self, e: Entity, value: T) -> Option<T>
Attach an attribute of type T
to the entity e
.
If there already was an attribute of type T
for that entity, the old
value is returned, and the after_remove
hook is run before inserting
the new value.
Sourcepub fn remove<T: 'static>(&mut self, e: Entity) -> Option<T>
pub fn remove<T: 'static>(&mut self, e: Entity) -> Option<T>
Remove the attribute of type T
from the entity e
.
If no attribute of that type exists on that entity, None
is returned.
Sourcepub fn update<T: 'static, R>(
&mut self,
e: Entity,
f: impl FnOnce(&mut T) -> R,
) -> Option<R>
pub fn update<T: 'static, R>( &mut self, e: Entity, f: impl FnOnce(&mut T) -> R, ) -> Option<R>
Update the attribute of type T
on the entity e
with the given
function.
If no attribute of that type exists on that entity, the function is
not executed and None
is returned.
If the attribute does exist, this will run both the after_remove
and the before_insert
hooks, with the previous and updated value
respectively.
Sourcepub fn upsert<T: Default + 'static, R>(
&mut self,
e: Entity,
f: impl FnOnce(&mut T) -> R,
) -> R
pub fn upsert<T: Default + 'static, R>( &mut self, e: Entity, f: impl FnOnce(&mut T) -> R, ) -> R
Update the attribute of type T
on the entity e
with the given
function.
If no attribute of that type exists on that entity, a defaut value is first inserted.
Like update
, this will run both after_remove
and
before_insert
hooks, unless the attribute didn’t exist yet, in which
case only the before_insert
hook is run.
Sourcepub fn get<T: 'static>(&self, e: Entity) -> Option<&T>
pub fn get<T: 'static>(&self, e: Entity) -> Option<&T>
Borrow the attribute of type T
on the entity e
.
If no attribute of that type exists on that entity, None
is returned.
Sourcepub fn contains<T: 'static>(&self, e: Entity) -> bool
pub fn contains<T: 'static>(&self, e: Entity) -> bool
Check whether the entity e
has an attribute of type T
.
Sourcepub fn iter<T: 'static>(&self) -> AttrIter<'_, T> ⓘ
pub fn iter<T: 'static>(&self) -> AttrIter<'_, T> ⓘ
Iterate over all entities with attribute of type T
.