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§
pub fn resolve_with_serde_context( pointer_address_with_ownership: PointerAddressWithOwnership, ctx: &SerdeContext<'_>, ) -> Result<Self, CacheValueRetrievalError>
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 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 owned SharedContainer containing an initial DatexNative value. The allowed type is the type of the DatexNative.
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 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>
Sourcepub fn update_observer_options(
&self,
observer_id: ObserverId,
options: ObserveOptions,
) -> Result<(), ObserverError>
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.
Sourcepub fn actual_type(&self) -> TypeDefinition
pub fn actual_type(&self) -> TypeDefinition
Gets the current actual TypeDefinition of the collapsed inner [Value]
pub fn collapsed_value(&self) -> CollapsedContainerValue<'_>
pub fn collapsed_value_mut(&self) -> CollapsedContainerValueMut<'_>
pub fn pointer_address(&self) -> PointerAddress
Sourcepub fn is_self_owned(&self) -> bool
pub fn is_self_owned(&self) -> bool
Returns true if the shared container has a self owned pointer address
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 downgrade_to_reference(&mut self) -> SharedContainer
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.
Sourcepub unsafe fn try_upgrade_to_owned(
self,
) -> Result<OwnedSharedContainer, ReferencedSharedContainer>
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.
Sourcepub fn clone_with_move_indicator_if_owned(&self) -> SharedContainer
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
Sourcepub fn treat_as_move(&self) -> bool
pub fn treat_as_move(&self) -> bool
Returns true if the shared container is an OwnedSharedContainer or a ReferencedSharedContainer that is marked as moved.
pub fn to_string_omit_content(&self) -> String
Sourcepub fn try_as<T>(&self) -> Option<Ref<'_, T>>where
T: ConvertValueContainer,
pub fn try_as<T>(&self) -> Option<Ref<'_, T>>where
T: ConvertValueContainer,
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.
Sourcepub fn try_as_mut<T>(&self) -> Option<SharedMut<'_, T>>where
T: ConvertValueContainer,
pub fn try_as_mut<T>(&self) -> Option<SharedMut<'_, T>>where
T: ConvertValueContainer,
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.
Sourcepub fn notify_borrow_dropped(&self)
pub fn notify_borrow_dropped(&self)
This method is called when a borrow of the inner shared container is dropped.
pub fn mark_debug(&self, is_debug: bool)
pub fn is_debug(&self) -> bool
Trait Implementations§
Source§fn try_apply_sync(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
fn try_apply_sync( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Source§async fn try_apply_async(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
async fn try_apply_async( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Source§fn try_apply_sync_checked(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
fn try_apply_sync_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Source§async fn try_apply_async_checked(
&self,
runtime: &Runtime,
args: Vec<ApplyArgument>,
) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
async fn try_apply_async_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>
Source§unsafe fn clone_unsafe(&self) -> Self
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§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,
fn deserialize_with_ctx<D: Deserializer<'de>>( ctx: &SerdeContext<'_>, d: D, ) -> Result<SharedContainer, D::Error>
Source§fn from(value: EntityType) -> Self
fn from(value: EntityType) -> Self
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(shared: SharedContainer) -> Self
fn from(shared: SharedContainer) -> Self
Source§fn from(value: SharedContainerContainingType) -> Self
fn from(value: SharedContainerContainingType) -> Self
fn datex_type(_context: &mut SharedReferencesCache) -> Type
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 inner 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 TypeDefinition of the shared container (not resolved recursively)
Source§fn can_mutate(&self) -> bool
fn can_mutate(&self) -> bool
Checks if the shared 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 ownership(&self) -> SharedContainerOwnership
fn ownership(&self) -> SharedContainerOwnership
Returns the SharedContainerOwnership of this shared container
Source§fn is_borrowed(&self) -> bool
fn is_borrowed(&self) -> bool
fn inner(&self) -> Ref<'_, SharedContainerInner>
fn inner_mut(&self) -> RefMut<'_, SharedContainerInner>
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: &'a mut SharedReferencesCache, ) -> Box<dyn Iterator<Item = Instruction> + 'a>
fn try_handle_update( &mut self, update: Update, cache: &RefCell<SharedReferencesCache>, ) -> UpdateResult
fn try_set_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: SetEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>
fn try_delete_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: DeleteEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>
fn try_append_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: AppendEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_clear( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>
fn try_list_splice( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: ListSpliceUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Vec<ValueContainer>, UpdateError>
fn try_increment( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: IncrementUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_decrement( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: DecrementUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_replace( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: ReplaceUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
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<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