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 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 fn new_native<T: DatexNative>(
value: T,
mutability: SharedContainerMutability,
address_provider: &mut SelfOwnedPointerAddressProvider,
cache: &mut SharedReferencesCache,
) -> Self
pub fn new_native<T: DatexNative>( value: T, mutability: SharedContainerMutability, address_provider: &mut SelfOwnedPointerAddressProvider, cache: &mut SharedReferencesCache, ) -> Self
Creates a new OwnedSharedContainer containing an initial DatexNative value. The allowed type is the type of the DatexNative.
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 new_unchecked(
container_mutability: SharedContainerMutability,
inner: Rc<RefCell<SharedContainerInner>>,
observer_data: Rc<RefCell<ObserverData>>,
) -> Self
pub unsafe fn new_unchecked( container_mutability: SharedContainerMutability, inner: Rc<RefCell<SharedContainerInner>>, observer_data: Rc<RefCell<ObserverData>>, ) -> Self
Creates a new OwnedSharedContainer from parts.
§Safety
This function should only be called if you can guarantee that no other OwnedSharedContainer exist that are using the same inner value.
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 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 fn clone_with_move_indicator(&self) -> ReferencedSharedContainer
pub fn clone_with_move_indicator(&self) -> ReferencedSharedContainer
Clones the shared container as a mutable reference if possible, otherwise as an immutable reference, and sets the move indicator on the cloned reference
Sourcepub unsafe fn move_to_remote(self, remote_address: RemotePointerAddress)
pub unsafe fn move_to_remote(self, remote_address: RemotePointerAddress)
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
pub fn to_string_omit_content(&self) -> String
Trait Implementations§
Source§unsafe fn clone_unsafe(&self) -> Self
unsafe fn clone_unsafe(&self) -> Self
Source§fn to_value_container(self) -> ValueContainer
fn to_value_container(self) -> ValueContainer
Source§fn as_borrowed_value_container(&self) -> BorrowedValueContainer<'_>
fn as_borrowed_value_container(&self) -> BorrowedValueContainer<'_>
Source§fn as_borrowed_value_container_mut(&mut self) -> BorrowedValueContainerMut<'_>
fn as_borrowed_value_container_mut(&mut self) -> BorrowedValueContainerMut<'_>
Source§fn try_from_value_container(
value_container: ValueContainer,
) -> Result<Self, ValueContainer>where
Self: Sized,
fn try_from_value_container(
value_container: ValueContainer,
) -> Result<Self, ValueContainer>where
Self: Sized,
Source§fn try_borrow_from_value_container(
value_container: &ValueContainer,
) -> Result<&Self, ()>where
Self: Sized,
fn try_borrow_from_value_container(
value_container: &ValueContainer,
) -> Result<&Self, ()>where
Self: Sized,
Source§fn try_borrow_mut_from_value_container(
value_container: &mut ValueContainer,
) -> Result<&mut Self, ()>where
Self: Sized,
fn try_borrow_mut_from_value_container(
value_container: &mut ValueContainer,
) -> Result<&mut Self, ()>where
Self: Sized,
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>
Source§fn try_convert_from_value_container(
value_container: ValueContainer,
) -> Result<Self, ()>
fn try_convert_from_value_container( value_container: ValueContainer, ) -> Result<Self, ()>
fn deserialize_with_ctx<D: Deserializer<'de>>( ctx: &SerdeContext<'_>, d: D, ) -> Result<OwnedSharedContainer, D::Error>
Source§fn from(value: OwnedSharedContainer) -> Self
fn from(value: OwnedSharedContainer) -> Self
Source§fn from(owned_shared_container: OwnedSharedContainer) -> Self
fn from(owned_shared_container: OwnedSharedContainer) -> Self
Source§fn from(shared: OwnedSharedContainer) -> Self
fn from(shared: OwnedSharedContainer) -> Self
Source§fn from(container: SelfOwnedSharedContainer) -> Self
fn from(container: SelfOwnedSharedContainer) -> Self
Source§fn try_from_map_parts(_parts: Map) -> Result<Self, ()>where
Self: Sized,
fn try_from_map_parts(_parts: Map) -> Result<Self, ()>where
Self: Sized,
Source§fn try_from_list_parts(_parts: List) -> Result<Self, ()>where
Self: Sized,
fn try_from_list_parts(_parts: List) -> Result<Self, ()>where
Self: Sized,
Source§fn try_from_single_value(_value: ValueContainer) -> Result<Self, ()>where
Self: Sized,
fn try_from_single_value(_value: ValueContainer) -> Result<Self, ()>where
Self: Sized,
fn try_from_map_parts_with_tag(
_parts: Map,
_tag: Option<&str>,
) -> Result<Self, ()>where
Self: Sized,
fn try_from_list_parts_with_tag(
_parts: List,
_tag: Option<&str>,
) -> Result<Self, ()>where
Self: Sized,
fn try_from_single_value_with_tag(
_value: ValueContainer,
_tag: Option<&str>,
) -> Result<Self, ()>where
Self: Sized,
fn datex_type(_context: &mut SharedReferencesCache) -> Type
Source§fn parts_kind(&self) -> PartsKind
fn parts_kind(&self) -> PartsKind
PartsKind::None, then the conversion is not possible.
If this returns PartsKind::List, then the conversion is possible and try_into_list_parts() can be called.
If this returns PartsKind::Map, then the conversion is possible and try_into_map_parts() can be called.
If this returns PartsKind::SingleValue, then the conversion is possible and try_from_single_value() can be called.Source§fn serialize_with_ctx<S>(
&self,
ctx: &SerdeContext<'_>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
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§fn container_mutability(&self) -> SharedContainerMutability
fn container_mutability(&self) -> SharedContainerMutability
Get the SharedContainerMutability of the container
Source§fn value_container(&self) -> Ref<'_, ValueContainer>
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>
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>
fn allowed_type(&self) -> Ref<'_, TypeDefinition>
Gets a Ref to the currently assigned allowed [Type] of the shared container (not resolved recursively)
Source§fn can_mutate(&self) -> bool
fn can_mutate(&self) -> bool
Checks if the owned container can be mutated by the local endpoint
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)
Source§fn is_borrowed(&self) -> bool
fn is_borrowed(&self) -> bool
fn inner(&self) -> Ref<'_, SharedContainerInner>
fn inner_mut(&self) -> RefMut<'_, SharedContainerInner>
Source§fn ownership(&self) -> SharedContainerOwnership
fn ownership(&self) -> SharedContainerOwnership
Source§fn observer_data(&self) -> Ref<'_, ObserverData>
fn observer_data(&self) -> Ref<'_, ObserverData>
Source§fn observer_data_mut(&self) -> RefMut<'_, ObserverData>
fn observer_data_mut(&self) -> RefMut<'_, ObserverData>
Source§fn is_uninitialized(&self) -> bool
fn is_uninitialized(&self) -> bool
Source§fn get_current_observers(
&self,
source_id: &TransceiverId,
) -> Vec<ObserverCallback>
fn get_current_observers( &self, source_id: &TransceiverId, ) -> Vec<ObserverCallback>
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
fn to_instructions<'a>( &'a self, visitor: &'a mut dyn ValueVisitor, cache: &mut SharedReferencesCache, ) -> Box<dyn Iterator<Item = Instruction> + 'a>
Source§type Error = OwnedSharedContainer
type Error = OwnedSharedContainer
Source§type Error = OwnedSharedContainer
type Error = OwnedSharedContainer
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> DeserializeWithSerdeContextDyn for Twhere
T: for<'de> DeserializeWithSerdeContext<'de>,
impl<T> DeserializeWithSerdeContextDyn for Twhere
T: for<'de> DeserializeWithSerdeContext<'de>,
fn deserialize_with_ctx_dyn<'de>( ctx: &SerdeContext<'_>, deserializer: &mut dyn Deserializer<'de>, ) -> Result<T, Error>
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> GetAllowedType for Twhere
T: GetDatexType,
impl<T> GetAllowedType for Twhere
T: GetDatexType,
fn allowed_type(&self, cache: &mut SharedReferencesCache) -> TypeDefinition
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