Skip to main content

ValueContainer

Enum ValueContainer 

Source
pub enum ValueContainer {
    Local(Value),
    Shared(SharedContainer),
}

Variants§

Implementations§

Source§

impl ValueContainer

Source

pub fn new_from_option(value: Option<ValueContainer>) -> ValueContainer

Unwraps an Option and returns a ValueContainer. If the Option is None, returns a ValueContainer containing a null value.

Source

pub fn local(value: impl Into<Value>) -> Self

Creates a new ValueContainer::Local from a Value

Source

pub fn owner(&self) -> Endpoint

Source

pub fn value_container(&self) -> Sheep<'_, ValueContainer>

Gets a reference to the inner ValueContainer, regardless of whether it is local or shared.

Source

pub fn value_container_mut(&mut self) -> SheepMut<'_, ValueContainer>

Gets a mutable reference to the inner ValueContainer, regardless of whether it is local or shared.

Source

pub fn collapsed_value(&self) -> CollapsedContainerValue<'_>

Source

pub fn collapsed_value_mut(&mut self) -> CollapsedContainerValueMut<'_>

Source

pub fn get_cloned_value(&self) -> Value

Gets a cloned, collapsed inner value. Use [ValueContainer::with_collapsed_value] instead whenever possible or match the ValueContainer

Source

pub fn try_as<T>(&self) -> Option<&T>

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.

Source

pub fn try_as_mut<T>(&mut self) -> Option<&mut T>

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.

Source

pub fn try_as_str(&self) -> Option<&str>

Tries to get an immutable reference to the value as a string slice. Does not perform any type conversion. In contrast to ValueContainer::try_as::(), this method also works for [Text] values containing a static string slice.

Source

pub fn try_into_value<T>(self) -> Result<T, ValueContainer>

Tries to get the current collapsed value as a specified type. Does not perform any type conversion. This only works for local values, not for shared values.

Source

pub fn try_convert_into_value<T>(self) -> Result<T, ()>

Tries to convert the current value into the specific specified type. Performs a cast between native and core values for local values if necessary, e.g. converting a [CoreValue::Map] into a native rust struct.

Source

pub fn without_local_observers(self) -> ValueContainer

Strips any local observers from the given value container. This method should be called when a value is moved from its SharedContainer parent.

Source

pub fn get_cloned(&self) -> ValueContainer

Performs a clone used by the “clone” command Local values are just cloned normally For shared value, the inner value container is cloned (shared x -> x)

Source

pub fn actual_type(&self) -> TypeDefinition

Returns the actual type of the contained value, resolving shared values if necessary.

Source

pub fn actual_container_type(&self) -> TypeDefinitionWithMetadata

Returns the actual type that describes the value container (e.g. integer or ’mut shared mut integer).

Source

pub fn allowed_or_actual_type(&self) -> Sheep<'_, TypeDefinition>

For local values, returns the actual type of the value container For shared values, returns the allowed type of the value container

Source

pub fn maybe_shared(&self) -> Option<&SharedContainer>

Returns the contained SharedContainer if it is a SharedContainer, otherwise returns None.

Source

pub fn maybe_shared_mut(&mut self) -> Option<&mut SharedContainer>

Returns a mutable reference to the contained SharedContainer if it is a SharedContainer, otherwise returns None.

Source

pub fn with_maybe_shared<F, R>(&self, f: F) -> Option<R>
where F: FnOnce(&SharedContainer) -> R,

Runs a closure with the contained SharedContainer if it is a SharedContainer, otherwise returns None.

Source

pub fn shared_unchecked(&self) -> &SharedContainer

Returns a reference to the contained SharedContainer, panics if it is not a SharedContainer.

Source

pub fn shared_unchecked_mut(&mut self) -> &mut SharedContainer

Source

pub fn is_uninitialized(&self) -> bool

Returns true if the underlying value is uninitialized (recursive).

Source

pub fn is_null(&self) -> bool

Trait Implementations§

Source§

impl Add for ValueContainer

Source§

type Output = Result<ValueContainer, ValueError>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ValueContainer) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&ValueContainer> for &ValueContainer

Source§

type Output = Result<ValueContainer, ValueError>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &ValueContainer) -> Self::Output

Performs the + operation. Read more
Source§

impl Apply for ValueContainer

Source§

fn try_apply_sync( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Applies multiple ValueContainer arguments to self Returns an Error if the value does not support sync apply. The return value is a tuple of the return value of the apply operation, and a vector containing all value containers for apply arguments that were passed as local references. Note: the count of the returned Vec corresponds to the count of arguments that have [passed_as_ref] set to true.
Source§

async fn try_apply_async( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Applies multiple ValueContainer arguments to self on a sync or async callable. The return value is a tuple of the return value of the apply operation, and a vector containing all value containers for apply arguments that were passed as local references. Note: the count of the returned Vec corresponds to the count of arguments that have [passed_as_ref] set to true.
Source§

fn try_apply_sync_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Calls the [try_apply_sync] method and checks that the number of returned local references matches the number of arguments that were passed as local references.
Source§

async fn try_apply_async_checked( &self, runtime: &Runtime, args: Vec<ApplyArgument>, ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError>

Calls the [try_apply_async] method and checks that the number of returned local references matches the number of arguments that were passed as local references.
Source§

impl Classification for ValueContainer

Source§

fn entity_type(&self, cache: &mut SharedReferencesCache) -> Option<EntityType>

Returns the DATEX EntityType of the native value if it has an entity type. For structural types, this will return None. The default implementation returns None, indicating that the value does not have an entity type.
Source§

fn entity_type_address(&self) -> Option<PointerAddress>

Returns the PointerAddress of the entity type if it has one. The default implementation returns None, indicating that the value does not have an entity type address. It must be ensured that the entity type for the given address is already registered in the runtime.
Source§

fn tag(&self) -> Option<ValueTag>

Returns a ValueTag if the value has a tag. The default implementation returns None, indicating that the value does not have a tag.
Source§

fn impls(&self) -> Vec<PointerAddress>

Returns a list of PointerAddresses of the impls associated with the value. The default implementation returns an empty list, indicating that the value does not have any impls.
Source§

fn classification( &self, cache: &mut SharedReferencesCache, ) -> ValueClassification

Returns the DATEX ValueClassification of the native value. This tries to resolve the entity type and tag, assuming at most one of them is present.
Source§

fn unresolved_classification(&self) -> UnresolvedValueClassification

Returns the unresolved DATEX UnresolvedValueClassification of the native value. This does not try to resolve the entity, but instead returns the address of the entity type if it has one.
Source§

impl Clone for ValueContainer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConvertValueContainer for ValueContainer

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 DatexHash for ValueContainer

Source§

fn datex_hash(&self, state: &mut dyn Hasher)

Source§

fn datex_hash_default(&self) -> u64

Source§

impl Debug for ValueContainer

Source§

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

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

impl<'de> Deserialize<'de> for ValueContainer

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> DeserializeWithSerdeContext<'de> for ValueContainer

Deserialization for ValueContainer using a SerdeContext to provide access to the memory during deserialization.

Source§

impl Display for ValueContainer

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 ValueContainer

Source§

impl<'a> From<&'a ValueContainer> for BorrowedValueContainer<'a>

Source§

fn from(value_container: &'a ValueContainer) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut ValueContainer> for BorrowedValueContainer<'a>

Source§

fn from(value_container: &'a mut ValueContainer) -> Self

Converts to this type from the input type.
Source§

impl From<ApplyArgument> for ValueContainer

Source§

fn from(arg: ApplyArgument) -> 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<ReferencedSharedContainer> for ValueContainer

Source§

fn from(shared: ReferencedSharedContainer) -> Self

Converts to this type from the input type.
Source§

impl From<SharedContainer> for ValueContainer

Source§

fn from(shared: SharedContainer) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value>> From<T> for ValueContainer

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl From<ValueContainer> for InstructionInput

Source§

fn from(value_container: ValueContainer) -> Self

Converts to this type from the input type.
Source§

impl From<ValueContainer> for ApplyArgument

Source§

fn from(value: ValueContainer) -> Self

Converts to this type from the input type.
Source§

impl From<ValueContainer> for UpdateReturn

Source§

fn from(value: ValueContainer) -> Self

Converts to this type from the input type.
Source§

impl FromParts for ValueContainer

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§

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§

impl GetCoreLibTypeId for ValueContainer

Source§

impl GetDatexType for ValueContainer

Source§

impl HasPartsKind for ValueContainer

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 ValueContainer

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 ValueContainer

Identity checks only returns true if two references are identical. Values are never identical to references or other values.

Source§

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

Check if two values are strictly identical (same pointer, same value, same type, same permissions).
Source§

impl IntoParts for ValueContainer

Source§

fn try_into_map_parts<'a>(self: Box<Self>) -> Result<Map, ()>
where Self: 'a,

Converts the implementing type into its map parts. Returns an error if the conversion is not possible. You can check if the conversion is possible by calling parts_kind() and checking if it returns PartsKind::Map.
Source§

fn try_into_list_parts<'a>(self: Box<Self>) -> Result<List, ()>
where Self: 'a,

Converts the implementing type into its list parts. Returns an error if the conversion is not possible. You can check if the conversion is possible by calling parts_kind() and checking if it returns PartsKind::List.
Source§

fn try_into_single_value<'a>(self: Box<Self>) -> Result<ValueContainer, ()>
where Self: 'a,

Converts the implementing type into a single value. Returns an error if the conversion is not possible. You can check if the conversion is possible by calling parts_kind() and checking if it returns PartsKind::SingleValue.
Source§

impl Neg for ValueContainer

Source§

type Output = Result<ValueContainer, ValueError>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for ValueContainer

Partial equality for ValueContainer is identical to Hash behavior: Identical references are partially equal, value-equal values are also partially equal. A pointer and a value are never partially equal.

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 Serialize for ValueContainer

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SerializeWithSerdeContext for ValueContainer

Source§

fn serialize_with_ctx<S>( &self, ctx: &SerdeContext<'_>, serializer: S, ) -> Result<S::Ok, S::Error>
where S: Serializer,

Source§

impl StructuralEq for ValueContainer

Structural equality checks the structural equality of the underlying values, collapsing references to their current resolved values.

Source§

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

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

impl Sub for ValueContainer

Source§

type Output = Result<ValueContainer, ValueError>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ValueContainer) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&ValueContainer> for &ValueContainer

Source§

type Output = Result<ValueContainer, ValueError>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &ValueContainer) -> Self::Output

Performs the - operation. Read more
Source§

impl ToInstructions for ValueContainer

Source§

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

Source§

impl<'a> TryFrom<&'a ValueContainer> for &'a str

Source§

type Error = ()

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

fn try_from(value: &'a ValueContainer) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a mut ValueContainer> for BorrowedValueContainerMut<'a>

Source§

type Error = ()

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

fn try_from( value_container: &'a mut ValueContainer, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<UpdateReturn> for ValueContainer

Source§

type Error = ()

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

fn try_from(value: UpdateReturn) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ValueContainer> for Type

Source§

type Error = ()

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

fn try_from(value: ValueContainer) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UpdateHandler for ValueContainer

Source§

fn try_handle_update( &mut self, update: Update, cache: &RefCell<SharedReferencesCache>, ) -> UpdateResult

Source§

fn try_set_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: SetEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>

Source§

fn try_delete_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: DeleteEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>

Source§

fn try_append_entry( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: AppendEntryUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

fn try_clear( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>

Source§

fn try_list_splice( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: ListSpliceUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<Vec<ValueContainer>, UpdateError>

Source§

fn try_increment( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: IncrementUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

fn try_decrement( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: DecrementUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

fn try_replace( &mut self, path: Vec<ValueContainer>, source_id: TransceiverId, data: ReplaceUpdateData, cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>

Source§

impl ValueEq for ValueContainer

Value equality checks the value equality of the underlying values, collapsing references to their current resolved values.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DatexNativeBase for T

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> SerializeWithSerdeContextDyn for T

Source§

fn with_ctx<'a>(&'a self, ctx: &'a SerdeContext<'a>) -> Box<dyn Serialize + 'a>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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