Skip to main content

OwnedSharedContainer

Struct OwnedSharedContainer 

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

Source§

impl OwnedSharedContainer

Source

pub fn new_from_self_owned_container( container: SelfOwnedSharedContainer, ) -> Self

Creates a new owned container from an SelfOwnedSharedContainer

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn as_self_owned_shared_container( &self, ) -> Ref<'_, SelfOwnedSharedContainer>

Get a Ref to the inner SelfOwnedSharedContainer. It is guaranteed that the contained SharedContainerInner is always a SharedContainerInner::EndpointOwned.

Source

pub fn as_self_owned_shared_container_mut( &self, ) -> RefMut<'_, SelfOwnedSharedContainer>

Get a RefMut to the inner SelfOwnedSharedContainer. It is guaranteed that the contained SharedContainerInner is always a SharedContainerInner::EndpointOwned.

Source

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.

Source

pub fn derive_immutable_reference(&self) -> ReferencedSharedContainer

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

Source

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

Source

pub fn derive_with_max_mutability(&self) -> ReferencedSharedContainer

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

Source

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

Source

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

Source

pub fn to_string_omit_content(&self) -> String

Trait Implementations§

Source§

impl CloneUnsafe for OwnedSharedContainer

Source§

unsafe fn clone_unsafe(&self) -> Self

Creates a new value with the same contents. This is used to allow exact clones of [SharedContainer]s, preserving ownership even for owned containers. Read more
Source§

impl ConvertValueContainer for OwnedSharedContainer

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§

fn try_from_bytes( dxb: Vec<u8>, runtime: &Runtime, ) -> Result<Self, DeserializationError>
where Self: Sized + FromParts,

Deserialize a value of type T from a byte slice containing DXB data
Source§

fn try_convert_from_value_container( value_container: ValueContainer, ) -> Result<Self, ()>
where Self: FromParts + Sized,

Tries to cast a ValueContainer into the specified type [T]. First, it attempts a direct conversion (downcast) of the ValueContainer into the type [T]. If that fails, it tries to convert the ValueContainer into map or list parts and then into the type [T].
Source§

impl Debug for OwnedSharedContainer

Source§

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

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

impl<'de> DeserializeWithSerdeContext<'de> for OwnedSharedContainer

Source§

impl Display for OwnedSharedContainer

Available on non-crate feature value_display only.
Source§

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

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

impl Eq for OwnedSharedContainer

Source§

impl From<OwnedSharedContainer> for SharedContainer

Source§

fn from(value: OwnedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<OwnedSharedContainer> for BorrowedValueContainer<'_>

Source§

fn from(owned_shared_container: OwnedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<OwnedSharedContainer> for ValueContainer

Source§

fn from(shared: OwnedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<SelfOwnedSharedContainer> for OwnedSharedContainer

Source§

fn from(container: SelfOwnedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl FromParts for OwnedSharedContainer

Source§

fn try_from_map_parts(_parts: Map) -> Result<Self, ()>
where Self: Sized,

Tries to construct the implementing type from the given map parts.
Source§

fn try_from_list_parts(_parts: List) -> Result<Self, ()>
where Self: Sized,

Tries to construct the implementing type from the given list parts.
Source§

fn try_from_single_value(_value: ValueContainer) -> Result<Self, ()>
where Self: Sized,

Tries to construct the implementing type from a single value.
Source§

fn try_from_map_parts_with_tag( _parts: Map, _tag: Option<&str>, ) -> Result<Self, ()>
where Self: Sized,

Source§

fn try_from_list_parts_with_tag( _parts: List, _tag: Option<&str>, ) -> Result<Self, ()>
where Self: Sized,

Source§

fn try_from_single_value_with_tag( _value: ValueContainer, _tag: Option<&str>, ) -> Result<Self, ()>
where Self: Sized,

Source§

impl GetDatexType for OwnedSharedContainer

Source§

impl HasPartsKind for OwnedSharedContainer

Source§

fn parts_kind(&self) -> PartsKind

Returns the kind of parts that the implementing type can be converted into. This can be used to check if the conversion is possible before attempting it. If this returns 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§

impl Hash for OwnedSharedContainer

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 OwnedSharedContainer

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 OwnedSharedContainer

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 OwnedSharedContainer

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 OwnedSharedContainer

Source§

fn container_mutability(&self) -> SharedContainerMutability

Get the SharedContainerMutability of the 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 [Type] of the shared container (not resolved recursively)

Source§

fn can_mutate(&self) -> bool

Checks if the owned 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 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 ownership(&self) -> SharedContainerOwnership

Returns the SharedContainerOwnership of this shared container
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 OwnedSharedContainer

Source§

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

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

impl ToInstructions for OwnedSharedContainer

Source§

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

Source§

impl<T: DatexNative + 'static> TryFrom<OwnedSharedContainer> for Shared<T>

Source§

type Error = OwnedSharedContainer

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

fn try_from(container: OwnedSharedContainer) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: DatexNative + 'static> TryFrom<OwnedSharedContainer> for SharedRef<T>

Source§

type Error = OwnedSharedContainer

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

fn try_from(container: OwnedSharedContainer) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl ValueEq for OwnedSharedContainer

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> 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> 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> 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