Skip to main content

SharedContainer

Enum SharedContainer 

Source
pub enum SharedContainer {
    Owned(OwnedSharedContainer),
    Referenced(ReferencedSharedContainer),
}
Expand description

Top-level wrapper for any owned or referenced shared container, which can either be an owned shared container or a reference to a shared container.

Variants§

§

Owned(OwnedSharedContainer)

An owned shared container (shared X). This is always points to a SharedContainerInner::EndpointOwned

§

Referenced(ReferencedSharedContainer)

A referenced shared container ('shared X or 'mut shared X). This can point to either a SharedContainerInner::EndpointOwned or a SharedContainerInner::External

Implementations§

Source§

impl SharedContainer

Source

pub fn resolve_with_serde_context( pointer_address_with_ownership: PointerAddressWithOwnership, ctx: &SerdeContext<'_>, ) -> Result<Self, CacheValueRetrievalError>

Source§

impl SharedContainer

Source

pub fn new_owned_with_inferred_allowed_type<T: Into<ValueContainer>>( value_container: T, mutability: SharedContainerMutability, address_provider: &mut SelfOwnedPointerAddressProvider, ) -> Self

Creates a new owned SharedContainer with an initial ValueContainer, a SharedContainerMutability, and a SelfOwnedPointerAddressProvider.

The allowed type is inferred from the value_container’s allowed type.

Source

pub fn new_native<T: DatexNative>( value: T, mutability: SharedContainerMutability, address_provider: &mut SelfOwnedPointerAddressProvider, cache: &mut SharedReferencesCache, ) -> Self

Creates a new owned SharedContainer containing an initial DatexNative value. The allowed type is the type of the DatexNative.

Source

pub unsafe fn new_owned_with_inferred_allowed_type_unsafe<T: Into<ValueContainer>>( value_container: T, mutability: SharedContainerMutability, address: SelfOwnedPointerAddress, ) -> Self

Creates a new owned SharedContainer with an initial ValueContainer, a SharedContainerMutability, and a SelfOwnedPointerAddress.

The allowed type is inferred from the value_container’s allowed type.

§Safety

The caller must ensure that the address is not used anywhere else.

Source

pub fn observe(&self, observer: Observer) -> Result<ObserverId, ObserverError>

Adds an observer to this shared container that will be notified on value changes.

Source

pub fn unobserve(&self, observer_id: ObserverId) -> Result<(), ObserverError>

Source

pub fn update_observer_options( &self, observer_id: ObserverId, options: ObserveOptions, ) -> Result<(), ObserverError>

Updates the options for an existing observer by its ID. Returns an error if the observer ID is not found or the reference is immutable.

Source

pub fn actual_type(&self) -> TypeDefinition

Gets the current actual TypeDefinition of the collapsed inner [Value]

Source

pub fn collapsed_value(&self) -> CollapsedContainerValue<'_>

Source

pub fn collapsed_value_mut(&self) -> CollapsedContainerValueMut<'_>

Source

pub fn pointer_address(&self) -> PointerAddress

Source

pub fn is_self_owned(&self) -> bool

Returns true if the shared container has a self owned pointer address

Source

pub fn derive_immutable_reference(&self) -> ReferencedSharedContainer

Creates a new immutable ReferencedSharedContainer pointing to the same inner value as self.

Source

pub fn try_derive_reference_with_mutability( &self, mutability: ReferenceMutability, ) -> Result<ReferencedSharedContainer, UnexpectedImmutableReferenceError>

Tries to create a new mutable or immutable ReferencedSharedContainer pointing to the same inner value as this OwnedSharedContainer. Returns an Err if the requested mutability is ReferenceMutability::Mutable, but the current reference_mutability is ReferenceMutability::Immutable or the container itself is not mutable

Source

pub fn try_derive_mutable_reference( &self, ) -> Result<ReferencedSharedContainer, UnexpectedImmutableReferenceError>

Tries to create a new mutable ReferencedSharedContainer pointing to the same inner value as this OwnedSharedContainer. Returns an Err if the current reference_mutability is ReferenceMutability::Immutable or the container itself is not mutable

Source

pub fn try_get_owned( &self, ) -> Result<&OwnedSharedContainer, UnexpectedSharedContainerOwnershipError>

Returns the owned shared container if it is owned, otherwise returns an error.

Source

pub fn derive_reference_with_max_mutability(&self) -> ReferencedSharedContainer

Clones the shared container as a mutable reference if possible, otherwise as an immutable reference

Source

pub fn downgrade_to_reference(&mut self) -> SharedContainer

Downgrades an owned shared container to a referenced shared container. If the shared container is already a referenced shared container, it will just be returned. If the shared container is owned, it will be replaced with a new referenced shared container pointing to the same inner value and the original owned shared container will be returned. Also sets the move indicator on the original owned shared container, so that we know it should be treated as moved.

Source

pub unsafe fn try_upgrade_to_owned( self, ) -> Result<OwnedSharedContainer, ReferencedSharedContainer>

Tries to upgrade an inner ReferencedSharedContainer to an OwnedSharedContainer. If the container is already an OwnedSharedContainer, it will be returned as is. If the move indicator is set, the inner value is moved into a new OwnedSharedContainer and returned. If the move indicator is not set, an Err is returned with the original ReferencedSharedContainer. Panics if the move indicator is set but the address is not a SelfOwnedPointerAddress.

§Safety

The caller must ensure that no other OwnedSharedContainer for the same inner value exists if move_indicator of the ReferencedSharedContainer is set.

Source

pub fn clone_with_move_indicator_if_owned(&self) -> SharedContainer

Clones the shared container with the move indicator if it is an OwnedSharedContainer, otherwise as a normal reference

Source

pub fn treat_as_move(&self) -> bool

Returns true if the shared container is an OwnedSharedContainer or a ReferencedSharedContainer that is marked as moved.

Source

pub fn to_string_omit_content(&self) -> String

Source

pub fn try_as<T>(&self) -> Option<Ref<'_, T>>

Tries to get an immutable reference to the value as a specified type. Does not perform any type conversion. This only works for local values, not for shared values.

Source

pub fn try_as_mut<T>(&self) -> Option<SharedMut<'_, T>>

Tries to get a mutable reference to the value as a specified type. Does not perform any type conversion. This only works for local values, not for shared values.

Source

pub fn notify_borrow_dropped(&self)

This method is called when a borrow of the inner shared container is dropped.

Source

pub fn mark_debug(&self, is_debug: bool)

Source

pub fn is_debug(&self) -> bool

Trait Implementations§

Source§

impl Apply for SharedContainer

Source§

fn try_apply_sync( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Applies multiple ValueContainer arguments to self Returns an Error if the value does not support sync apply. The return value is a tuple of the return value of the apply operation, and a vector containing all value containers for apply arguments that were passed as local references. Note: the count of the returned Vec corresponds to the count of arguments that have [passed_as_ref] set to true.
Source§

async fn try_apply_async( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Applies multiple ValueContainer arguments to self on a sync or async callable. The return value is a tuple of the return value of the apply operation, and a vector containing all value containers for apply arguments that were passed as local references. Note: the count of the returned Vec corresponds to the count of arguments that have [passed_as_ref] set to true.
Source§

fn try_apply_sync_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Calls the [try_apply_sync] method and checks that the number of returned local references matches the number of arguments that were passed as local references.
Source§

async fn try_apply_async_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Calls the [try_apply_async] method and checks that the number of returned local references matches the number of arguments that were passed as local references.
Source§

impl Clone for SharedContainer

Custom clone implementation for SharedContainer. A SharedContainer::Owned cannot be cloned as is, only a new reference can be created A SharedContainer::Referenced can be cloned normally

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CloneUnsafe for SharedContainer

Source§

unsafe fn clone_unsafe(&self) -> Self

Creates a new owned SharedContainer with the same contents.

§Safety

The caller must ensure that the original self is not used later or that the newly created shared container is only used internally and dropped afterward.

Source§

impl ConvertValueContainer for SharedContainer

Source§

fn to_value_container(self) -> ValueContainer

Convert the value to a ValueContainer
Source§

fn as_borrowed_value_container(&self) -> BorrowedValueContainer<'_>

Borrow the value as a BorrowedValueContainer
Source§

fn as_borrowed_value_container_mut(&mut self) -> BorrowedValueContainerMut<'_>

Borrow the value as a mutable BorrowedValueContainer
Source§

fn try_from_value_container( value_container: ValueContainer, ) -> Result<Self, ValueContainer>
where Self: Sized,

Tries to downcast a ValueContainer into Self
Source§

fn try_borrow_from_value_container( value_container: &ValueContainer, ) -> Result<&Self, ()>
where Self: Sized,

Tries to downcast a ValueContainer into a reference of Self
Source§

fn try_borrow_mut_from_value_container( value_container: &mut ValueContainer, ) -> Result<&mut Self, ()>
where Self: Sized,

Tries to downcast a ValueContainer into a mutable reference of Self
Source§

impl Debug for SharedContainer

Source§

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

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

impl<'de> DeserializeWithSerdeContext<'de> for SharedContainer

Source§

impl Display for SharedContainer

Source§

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

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

impl Eq for SharedContainer

Source§

impl From<EntityType> for SharedContainer

Source§

fn from(value: EntityType) -> Self

Converts to this type from the input type.
Source§

impl From<OwnedSharedContainer> for SharedContainer

Source§

fn from(value: OwnedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<ReferencedSharedContainer> for SharedContainer

Source§

fn from(value: ReferencedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<SharedContainer> for BorrowedValueContainer<'_>

Source§

fn from(shared_container: SharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<SharedContainer> for ValueContainer

Source§

fn from(shared: SharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<SharedContainerContainingType> for SharedContainer

Source§

fn from(value: SharedContainerContainingType) -> Self

Converts to this type from the input type.
Source§

impl GetDatexType for SharedContainer

Source§

impl Hash for SharedContainer

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Identity for SharedContainer

Two references are identical if they point to the same inner value (Rc pointer equality)

Source§

fn identical(&self, other: &Self) -> bool

Check if two values are strictly identical (same pointer, same value, same type, same permissions).
Source§

impl PartialEq for SharedContainer

PartialEq corresponds to pointer equality / identity for Reference.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl SerializeWithSerdeContext for SharedContainer

Source§

fn serialize_with_ctx<S>( &self, ctx: &SerdeContext<'_>, serializer: S, ) -> Result<S::Ok, S::Error>
where S: Serializer,

SAFETY: The caller of the serialize method must either

  • guarantee that no direct value (accessible without borrow) is an owned shared value (this can be guaranteed by calling clone on the top level value before passing it to SerializeWithSerdeContext)
  • or guarantee that the value is dropped after calling serialize, so that the owned shared value is not leaked after serialization.
Source§

impl SharedContainerCommon for SharedContainer

Source§

fn container_mutability(&self) -> SharedContainerMutability

Get the SharedContainerMutability of the inner container.

Source§

fn value_container(&self) -> Ref<'_, ValueContainer>

Gets a Ref to the currently assigned ValueContainer of the shared container (not resolved recursively)

Source§

fn value_container_mut(&self) -> RefMut<'_, ValueContainer>

Gets a RefMut to the currently assigned ValueContainer of the shared container (not resolved recursively)

Source§

fn allowed_type(&self) -> Ref<'_, TypeDefinition>

Gets a Ref to the currently assigned allowed TypeDefinition of the shared container (not resolved recursively)

Source§

fn can_mutate(&self) -> bool

Checks if the shared container can be mutated by the local endpoint

Source§

fn base_shared_container(&self) -> Ref<'_, BaseSharedValueContainer>

Gets a Ref to the currently assigned BaseSharedValueContainer of the shared container (not resolved recursively)

Source§

fn base_shared_container_mut(&self) -> RefMut<'_, BaseSharedValueContainer>

Gets a RefMut to the currently assigned BaseSharedValueContainer of the shared container (not resolved recursively)

Source§

fn ownership(&self) -> SharedContainerOwnership

Returns the SharedContainerOwnership of this shared container

Source§

fn is_borrowed(&self) -> bool

Checks if the Rc in the shared container is currently borrowed mutably or immutably
Source§

fn inner(&self) -> Ref<'_, SharedContainerInner>

Source§

fn inner_mut(&self) -> RefMut<'_, SharedContainerInner>

Source§

fn observer_data(&self) -> Ref<'_, ObserverData>

Returns a reference to the observer data of the shared container
Source§

fn observer_data_mut(&self) -> RefMut<'_, ObserverData>

Returns a mutable reference to the observer data of the shared container
Source§

fn is_uninitialized(&self) -> bool

Returns true if the shared container is uninitialized (i.e., it has no value assigned yet)
Source§

fn get_current_observers( &self, source_id: &TransceiverId, ) -> Vec<ObserverCallback>

Returns a list of all ObserverCallbacks that are currently active for the given TransceiverId
Source§

impl StructuralEq for SharedContainer

Source§

fn structural_eq(&self, other: &Self) -> bool

Check if two values are equal, ignoring the type.
Source§

impl ToInstructions for SharedContainer

Source§

fn to_instructions<'a>( &'a self, visitor: &'a mut dyn ValueVisitor, cache: &'a mut SharedReferencesCache, ) -> Box<dyn Iterator<Item = Instruction> + 'a>

Source§

impl TryFrom<SharedContainer> for EntityType

Source§

type Error = ()

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

fn try_from(value: SharedContainer) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<SharedContainer> for SharedContainerContainingType

Source§

type Error = ()

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

fn try_from(value: SharedContainer) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UpdateHandler for SharedContainer

Source§

fn try_handle_update( &mut self, update: Update, cache: &RefCell<SharedReferencesCache>, ) -> UpdateResult

Source§

fn try_set_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: SetEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>

Source§

fn try_delete_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: DeleteEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>

Source§

fn try_append_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: AppendEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

fn try_clear( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>

Source§

fn try_list_splice( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: ListSpliceUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Vec<ValueContainer>, UpdateError>

Source§

fn try_increment( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: IncrementUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

fn try_decrement( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: DecrementUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

fn try_replace( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: ReplaceUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

impl ValueEq for SharedContainer

Source§

fn value_eq(&self, other: &Self) -> bool

Check if two values are exactly equal, including the type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeWithSerdeContextDyn for T
where T: for<'de> DeserializeWithSerdeContext<'de>,

Source§

fn deserialize_with_ctx_dyn<'de>( ctx: &SerdeContext<'_>, deserializer: &mut dyn Deserializer<'de>, ) -> Result<T, Error>

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

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

Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetAllowedType for T
where T: GetDatexType,

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> SerializeWithSerdeContextDyn for T

Source§

fn with_ctx<'a>(&'a self, ctx: &'a SerdeContext<'a>) -> Box<dyn Serialize + 'a>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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