pub struct SharedReferencesCache { /* private fields */ }Implementations§
Registers a remote shared container in the cache. This method should be called for shared containers that this endpoint is currently subscribed to and receives updates for. If the reference is already registered (has a PointerAddress), the existing address is returned and no new registration is done. The reference is stored as a weak reference, so it will be dropped when there are no more strong references to it. TODO: call remove on Rc drop!
Registers an owned shared container in the cache. This method should be called for shared containers that this endpoint owns and is responsible for. If the reference is already registered (has a PointerAddress), the existing address is returned and no new registration is done. The reference is stored as a strong reference, so it will not be dropped until it is explicitly removed from the cache.
Removes a remote shared container from the cache.
Removes an owned shared container from the cache.
Sourcepub fn get_reference(
&self,
pointer_address: &PointerAddress,
) -> Option<ReferencedSharedContainer>
pub fn get_reference( &self, pointer_address: &PointerAddress, ) -> Option<ReferencedSharedContainer>
Returns a reference stored at the given PointerAddress, if it exists.
Sourcepub fn get_owned_reference(
&self,
pointer_address: &PointerAddress,
) -> Option<&ReferencedSharedContainer>
pub fn get_owned_reference( &self, pointer_address: &PointerAddress, ) -> Option<&ReferencedSharedContainer>
Returns a reference to an owned shared container stored at the given PointerAddress, if it exists.
Sourcepub fn get_remote_reference(
&self,
pointer_address: &PointerAddress,
) -> Option<ReferencedSharedContainer>
pub fn get_remote_reference( &self, pointer_address: &PointerAddress, ) -> Option<ReferencedSharedContainer>
Returns a reference to a remote shared container stored at the given PointerAddress, if it exists and is still alive.
Sourcepub fn has_reference(&self, pointer_address: &PointerAddress) -> bool
pub fn has_reference(&self, pointer_address: &PointerAddress) -> bool
Checks if a reference with the given PointerAddress exists in memory.
Sourcepub fn values(&self) -> impl Iterator<Item = ReferencedSharedContainer>
pub fn values(&self) -> impl Iterator<Item = ReferencedSharedContainer>
Returns an iterator over all currently stored references in the cache, both owned and remote.
Sourcepub fn owned_values(&self) -> impl Iterator<Item = &ReferencedSharedContainer>
pub fn owned_values(&self) -> impl Iterator<Item = &ReferencedSharedContainer>
Returns an iterator over all currently stored owned references in the cache.
Sourcepub fn remote_values(&self) -> impl Iterator<Item = ReferencedSharedContainer>
pub fn remote_values(&self) -> impl Iterator<Item = ReferencedSharedContainer>
Returns an iterator over all currently stored remote references in the cache.
Sourcepub fn remote_values_weak(&self) -> impl Iterator<Item = &WeakSharedContainer>
pub fn remote_values_weak(&self) -> impl Iterator<Item = &WeakSharedContainer>
Returns an iterator over all currently stored remote weak references in the cache.
Tries to get a shared container containing an EntityTypeDefinition from the cache for the given SelfOwnedPointerAddress. Returns the EntityType if found, or None if not found
Registers a new shared container type in the cache for the given address and returns the registered container as a EntityType.
§Safety
The caller must ensure that the address is not used anywhere else.
Sourcepub unsafe fn init_entity_type<T>(
&mut self,
address: PointerAddress,
generate: impl FnOnce(&mut Self) -> (String, TypeDefinition),
) -> EntityTypewhere
T: for<'de> DeserializeWithSerdeContext<'de> + ConvertValue + 'static,
pub unsafe fn init_entity_type<T>(
&mut self,
address: PointerAddress,
generate: impl FnOnce(&mut Self) -> (String, TypeDefinition),
) -> EntityTypewhere
T: for<'de> DeserializeWithSerdeContext<'de> + ConvertValue + 'static,
Generates or retrieves an EntityType for the given type T, using the provided address and generation function. If the type is already registered in the cache, it returns the existing EntityType. If not, it generates a new EntityTypeDefinition using the provided closure and registers it in the cache.
§Safety
The caller must ensure that the address is unique.
Reserves a shared container type in the cache for the given address and returns a SharedTypeReservation.
§Safety
The caller must ensure that the address is unique.
Finishes the registration of a shared container type in the cache for the given address and definition. This method should be called after reserve_shared_type to set the actual EntityTypeDefinition for the reserved shared container. It will panic if the type is not in the cache or if it is already initialized.
Sourcepub fn resolve_structural_type<T, F>(&mut self, f: F) -> Type
pub fn resolve_structural_type<T, F>(&mut self, f: F) -> Type
Resolves a structural type for the given type T, ensuring that recursive types are not allowed.
Sourcepub fn with_entity_boundary<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(&mut Self) -> R,
pub fn with_entity_boundary<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(&mut Self) -> R,
Executes the given closure with a temporary entity boundary, which allows resolving structural types within the closure without affecting the outer context.
Trait Implementations§
Auto Trait Implementations§
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> 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