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§
Sourcepub fn new_owned_with_inferred_allowed_type<T: Into<ValueContainer>>(
value_container: T,
mutability: SharedContainerMutability,
address_provider: &mut SelfOwnedPointerAddressProvider,
) -> Self
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.
Sourcepub unsafe fn new_owned_with_inferred_allowed_type_unsafe<T: Into<ValueContainer>>(
value_container: T,
mutability: SharedContainerMutability,
address: SelfOwnedPointerAddress,
) -> Self
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.
Sourcepub unsafe fn clone_unsafe(&self) -> Self
pub unsafe fn clone_unsafe(&self) -> Self
Creates a new owned SharedContainer with the same contents.
§Safety
The caller must be sure, that the reference on the original self is not used later.
pub fn inner(&self) -> Ref<'_, SharedContainerInner>
pub fn inner_mut(&self) -> RefMut<'_, SharedContainerInner>
Gets a Ref to the currently assigned BaseSharedValueContainer of the shared container (not resolved recursively)
Sourcepub fn observe(&self, observer: Observer) -> Result<ObserverId, ObserverError>
pub fn observe(&self, observer: Observer) -> Result<ObserverId, ObserverError>
Adds an observer to this shared container that will be notified on value changes.
pub fn unobserve(&self, observer_id: ObserverId) -> Result<(), ObserverError>
Gets a RefMut to the currently assigned BaseSharedValueContainer of the shared container (not resolved recursively)
Sourcepub fn value_container(&self) -> Ref<'_, ValueContainer>
pub fn value_container(&self) -> Ref<'_, ValueContainer>
Gets a Ref to the currently assigned ValueContainer of the shared container (not resolved recursively)
Sourcepub fn allowed_type(&self) -> Ref<'_, TypeDefinition>
pub fn allowed_type(&self) -> Ref<'_, TypeDefinition>
Gets a Ref to the currently assigned allowed TypeDefinition of the shared container (not resolved recursively)
Sourcepub fn actual_type(&self) -> TypeDefinition
pub fn actual_type(&self) -> TypeDefinition
Gets the current actual TypeDefinition of the collapsed inner Value
Sourcepub fn value_container_mut(&self) -> RefMut<'_, ValueContainer>
pub fn value_container_mut(&self) -> RefMut<'_, ValueContainer>
Gets a RefMut to the currently assigned ValueContainer of the shared container (not resolved recursively)
Sourcepub fn container_mutability(&self) -> SharedContainerMutability
pub fn container_mutability(&self) -> SharedContainerMutability
Get the SharedContainerMutability of the inner container.
Sourcepub fn with_collapsed_value_mut<R>(&self, f: impl FnOnce(&mut Value) -> R) -> R
pub fn with_collapsed_value_mut<R>(&self, f: impl FnOnce(&mut Value) -> R) -> R
Calls the provided callback with a mut reference to the recursively collapsed inner value of the shared container
Sourcepub fn with_collapsed_value<R>(&self, f: impl FnOnce(&Value) -> R) -> R
pub fn with_collapsed_value<R>(&self, f: impl FnOnce(&Value) -> R) -> R
Calls the provided callback with a reference to the recursively collapsed inner value of the shared container
pub fn try_get_property<'a>( &self, key: impl Into<BorrowedValueKey<'a>>, ) -> Result<ValueContainer, AccessError>
pub fn pointer_address(&self) -> PointerAddress
Sourcepub fn derive_immutable_reference(&self) -> ReferencedSharedContainer
pub fn derive_immutable_reference(&self) -> ReferencedSharedContainer
Creates a new immutable ReferencedSharedContainer pointing to the same inner value as self.
Sourcepub fn try_derive_reference_with_mutability(
&self,
mutability: ReferenceMutability,
) -> Result<ReferencedSharedContainer, UnexpectedImmutableReferenceError>
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
Sourcepub fn try_derive_mutable_reference(
&self,
) -> Result<ReferencedSharedContainer, UnexpectedImmutableReferenceError>
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
Sourcepub fn try_get_owned(
&self,
) -> Result<&OwnedSharedContainer, UnexpectedSharedContainerOwnershipError>
pub fn try_get_owned( &self, ) -> Result<&OwnedSharedContainer, UnexpectedSharedContainerOwnershipError>
Returns the owned shared container if it is owned, otherwise returns an error.
Sourcepub fn derive_reference_with_max_mutability(&self) -> ReferencedSharedContainer
pub fn derive_reference_with_max_mutability(&self) -> ReferencedSharedContainer
Clones the shared container as a mutable reference if possible, otherwise as an immutable reference
Sourcepub fn can_mutate(&self) -> bool
pub fn can_mutate(&self) -> bool
Checks if the shared container can be mutated by the local endpoint
Sourcepub fn ownership(&self) -> SharedContainerOwnership
pub fn ownership(&self) -> SharedContainerOwnership
Returns the SharedContainerOwnership of this shared container
Trait Implementations§
Source§fn try_apply(
&self,
args: &[ValueContainer],
) -> Result<Option<ValueContainer>, ApplyError>
fn try_apply( &self, args: &[ValueContainer], ) -> Result<Option<ValueContainer>, ApplyError>
Source§fn try_apply_single(
&self,
arg: &ValueContainer,
) -> Result<Option<ValueContainer>, ApplyError>
fn try_apply_single( &self, arg: &ValueContainer, ) -> Result<Option<ValueContainer>, ApplyError>
fn datex_type(_memory: &mut SharedReferencesCache) -> Type
fn try_from_value_container( value: ValueContainer, ) -> Result<Self, TryFromDatexValueError>
fn try_from_map_property( value: Result<ValueContainer, KeyNotFoundError>, ) -> Result<Self, TryFromDatexValueError>
Source§fn try_from_bytes(
dxb: Vec<u8>,
runtime: &Runtime,
) -> Result<Self, DeserializationError>
fn try_from_bytes( dxb: Vec<u8>, runtime: &Runtime, ) -> Result<Self, DeserializationError>
fn to_value_container(self) -> ValueContainer
Source§fn from(value: OwnedSharedContainer) -> Self
fn from(value: OwnedSharedContainer) -> Self
Source§fn from(value: ReferencedSharedContainer) -> Self
fn from(value: ReferencedSharedContainer) -> Self
Source§fn from(shared_container: SharedContainer) -> Self
fn from(shared_container: SharedContainer) -> Self
Source§fn from(value: SharedContainerContainingNominalType) -> Self
fn from(value: SharedContainerContainingNominalType) -> Self
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
Source§type Error = TryFromDatexValueError
type Error = TryFromDatexValueError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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