pub struct WeakEntitySet(/* private fields */);Expand description
A set of entities held weakly
Implementations§
Source§impl WeakEntitySet
impl WeakEntitySet
pub fn get(&self, id: &EntityId) -> Option<Entity>
pub async fn get_or_retrieve<S, E>( &self, state_getter: &S, event_getter: &E, collection_id: &CollectionId, id: &EntityId, ) -> Result<Option<Entity>, RetrievalError>
Sourcepub async fn get_retrieve_or_create<S, E>(
&self,
state_getter: &S,
event_getter: &E,
collection_id: &CollectionId,
id: &EntityId,
) -> Result<Entity, RetrievalError>
pub async fn get_retrieve_or_create<S, E>( &self, state_getter: &S, event_getter: &E, collection_id: &CollectionId, id: &EntityId, ) -> Result<Entity, RetrievalError>
Returns a resident entity, or fetches it from storage, or finally creates if neither of the two are found
Sourcepub fn create(&self, collection: CollectionId) -> Entity
pub fn create(&self, collection: CollectionId) -> Entity
Create a brand new entity, and add it to the set
Sourcepub fn remove_if_phantom(&self, id: &EntityId) -> bool
pub fn remove_if_phantom(&self, id: &EntityId) -> bool
Evict an entity from the set only if it is absent from storage-backed life: resident with an empty head (or already dead). An empty-head resident is a phantom, materialized speculatively for an incoming update that then failed to apply; leaving it resident makes the entity appear to exist with no state. Returns true if an entry was removed.
Sourcepub async fn with_state<S, E>(
&self,
state_getter: &S,
event_getter: &E,
id: EntityId,
collection_id: CollectionId,
state: State,
) -> Result<(Option<bool>, Entity), RetrievalError>
pub async fn with_state<S, E>( &self, state_getter: &S, event_getter: &E, id: EntityId, collection_id: CollectionId, state: State, ) -> Result<(Option<bool>, Entity), RetrievalError>
Returns a tuple of (changed, entity) changed is Some(true) if the entity was changed, Some(false) if it already exists and the state was not applied None if the entity was not previously on the local node (either in the WeakEntitySet or in storage)
Trait Implementations§
Source§impl Clone for WeakEntitySet
impl Clone for WeakEntitySet
Source§fn clone(&self) -> WeakEntitySet
fn clone(&self) -> WeakEntitySet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for WeakEntitySet
impl Default for WeakEntitySet
Source§fn default() -> WeakEntitySet
fn default() -> WeakEntitySet
Auto Trait Implementations§
impl Freeze for WeakEntitySet
impl RefUnwindSafe for WeakEntitySet
impl Send for WeakEntitySet
impl Sync for WeakEntitySet
impl Unpin for WeakEntitySet
impl UnsafeUnpin for WeakEntitySet
impl UnwindSafe for WeakEntitySet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more