Skip to main content

SharedReferencesCache

Struct SharedReferencesCache 

Source
pub struct SharedReferencesCache { /* private fields */ }

Implementations§

Source§

impl SharedReferencesCache

Source

pub fn register_remote_shared_container( &mut self, container: &ReferencedSharedContainer, )

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!

Source

pub fn register_owned_shared_container( &mut self, container: &ReferencedSharedContainer, )

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.

Source

pub fn remove_remote_shared_container( &mut self, pointer_address: &PointerAddress, )

Removes a remote shared container from the cache.

Source

pub fn remove_owned_shared_container( &mut self, pointer_address: &PointerAddress, )

Removes an owned shared container from the cache.

Source

pub fn get_reference( &self, pointer_address: &PointerAddress, ) -> Option<ReferencedSharedContainer>

Returns a reference stored at the given PointerAddress, if it exists.

Source

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.

Source

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.

Source

pub fn has_reference(&self, pointer_address: &PointerAddress) -> bool

Checks if a reference with the given PointerAddress exists in memory.

Source

pub fn values(&self) -> impl Iterator<Item = ReferencedSharedContainer>

Returns an iterator over all currently stored references in the cache, both owned and remote.

Source

pub fn owned_values(&self) -> impl Iterator<Item = &ReferencedSharedContainer>

Returns an iterator over all currently stored owned references in the cache.

Source

pub fn remote_values(&self) -> impl Iterator<Item = ReferencedSharedContainer>

Returns an iterator over all currently stored remote references in the cache.

Source

pub fn remote_values_weak(&self) -> impl Iterator<Item = &WeakSharedContainer>

Returns an iterator over all currently stored remote weak references in the cache.

Source

pub fn try_get_shared_type( &mut self, address: SelfOwnedPointerAddress, ) -> Option<EntityType>

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

Source

pub unsafe fn register_shared_type( &mut self, address: SelfOwnedPointerAddress, entity_type_definition: EntityTypeDefinition, ) -> EntityType

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.

Source

pub unsafe fn init_entity_type<T>( &mut self, address: PointerAddress, generate: impl FnOnce(&mut Self) -> (String, TypeDefinition), ) -> EntityType
where 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.

Source

pub unsafe fn reserve_shared_type( &mut self, address: PointerAddress, ) -> SharedTypeReservation

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.

Source

pub fn finish_shared_type( &mut self, address: PointerAddress, definition: EntityTypeDefinition, )

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.

Source

pub fn resolve_structural_type<T, F>(&mut self, f: F) -> Type
where T: 'static, F: FnOnce(&mut Self) -> Type,

Resolves a structural type for the given type T, ensuring that recursive types are not allowed.

Source

pub fn with_entity_boundary<F, R>(&mut self, f: F) -> R
where 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§

Source§

impl Debug for SharedReferencesCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SharedReferencesCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> DynEq for T
where T: Any,

Source§

default fn dyn_eq(&self, _other: &(dyn Any + 'static)) -> bool

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> TryClone for T

Source§

default fn try_clone(&self) -> Result<Value, ()>

Attempts to clone Self into a new Value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TypeSubset<U> for T
where U: TypeSuperset<T>,

Source§

fn is_subset_of(&self, other: &U) -> bool

Returns whether self is a subset of type