pub struct OwnedSharedContainer { /* private fields */ }Expand description
Wrapper struct for an owned shared value (i.e. shared X)
It is guaranteed that the inner value is a SharedContainerInner::EndpointOwned.
(OwnedSharedContainer implies SharedContainerInner::EndpointOwned, but not vice versa, since a SharedContainerInner::EndpointOwned can be wrapped in a ReferencedSharedContainer)
When holding an OwnedSharedContainer, it is guaranteed that the contained SharedContainerInner is not moved and changed to SharedContainerInner::External. Only an OwnedSharedContainer can be moved to another endpoint or location.
Implementations§
Sourcepub fn new_from_self_owned_container(
container: SelfOwnedSharedContainer,
) -> Self
pub fn new_from_self_owned_container( container: SelfOwnedSharedContainer, ) -> Self
Creates a new owned container from an SelfOwnedSharedContainer
Sourcepub fn try_new(
value_container: ValueContainer,
allowed_type: TypeDefinition,
mutability: SharedContainerMutability,
address: SelfOwnedPointerAddress,
) -> Result<Self, SharedValueCreationError>
pub fn try_new( value_container: ValueContainer, allowed_type: TypeDefinition, mutability: SharedContainerMutability, address: SelfOwnedPointerAddress, ) -> Result<Self, SharedValueCreationError>
Tries to create a new OwnedSharedContainer with an initial ValueContainer, an allowed TypeDefinition, a SharedContainerMutability and an SelfOwnedPointerAddress.
If the allowed type is not a superset of the ValueContainer’s allowed type, an error is returned
Sourcepub fn new_with_inferred_allowed_type<T: Into<ValueContainer>>(
value_container: T,
mutability: SharedContainerMutability,
address_provider: &mut SelfOwnedPointerAddressProvider,
) -> Self
pub fn new_with_inferred_allowed_type<T: Into<ValueContainer>>( value_container: T, mutability: SharedContainerMutability, address_provider: &mut SelfOwnedPointerAddressProvider, ) -> Self
Creates a new OwnedSharedContainer with an initial ValueContainer, a SharedContainerMutability, and an SelfOwnedPointerAddress.
The allowed type is inferred from the value_container’s allowed type.
Sourcepub unsafe fn new_with_inferred_allowed_type_unsafe(
value_container: ValueContainer,
mutability: SharedContainerMutability,
address: SelfOwnedPointerAddress,
) -> Self
pub unsafe fn new_with_inferred_allowed_type_unsafe( value_container: ValueContainer, mutability: SharedContainerMutability, address: SelfOwnedPointerAddress, ) -> Self
Creates a new OwnedSharedContainer with an initial ValueContainer, a SharedContainerMutability, and an 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 OwnedSharedContainer with the same inner value as the current one.
§Safety
The caller must ensure 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)
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 [Type] of the shared container (not resolved recursively)
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 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
Get a Ref to the inner SelfOwnedSharedContainer. It is guaranteed that the contained SharedContainerInner is always a SharedContainerInner::EndpointOwned.
Get a RefMut to the inner SelfOwnedSharedContainer. It is guaranteed that the contained SharedContainerInner is always a SharedContainerInner::EndpointOwned.
Sourcepub fn pointer_address(&self) -> Ref<'_, SelfOwnedPointerAddress>
pub fn pointer_address(&self) -> Ref<'_, SelfOwnedPointerAddress>
Get a Ref to the inner SelfOwnedPointerAddress. It is guaranteed that the pointer address is always a SelfOwnedPointerAddress.
Sourcepub fn container_mutability(&self) -> SharedContainerMutability
pub fn container_mutability(&self) -> SharedContainerMutability
Get the SharedContainerMutability of the inner SelfOwnedSharedContainer.
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 this OwnedSharedContainer.
Sourcepub fn try_derive_mutable_reference(
&self,
) -> Result<ReferencedSharedContainer, UnexpectedImmutableSharedContainerError>
pub fn try_derive_mutable_reference( &self, ) -> Result<ReferencedSharedContainer, UnexpectedImmutableSharedContainerError>
Tries to create a new mutable ReferencedSharedContainer pointing to the same inner value as this OwnedSharedContainer. Returns an Err if the container itself is not mutable
Sourcepub fn derive_with_max_mutability(&self) -> ReferencedSharedContainer
pub fn derive_with_max_mutability(&self) -> ReferencedSharedContainer
Clones the shared container as a mutable reference if possible, otherwise as an immutable reference
Sourcepub unsafe fn move_to_remote(
self,
remote_address: RemotePointerAddress,
memory: &SharedReferencesCache,
)
pub unsafe fn move_to_remote( self, remote_address: RemotePointerAddress, memory: &SharedReferencesCache, )
Moves an owned shared container by converting it to a ReferencedSharedContainer with a RemotePointerAddress pointing to the given remote address. Drops the original owned shared container
§Safety
The caller must ensure that the RemotePointerAddress does not yet exist in the SharedReferencesCache
Trait Implementations§
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 structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
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<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