pub enum Value {
Core(CoreValueWithClassification),
Native(NativeCoreValue),
}Expand description
Represents a local DATEX value. This can either be a core value with classification or a native rust value that provides all trait implementations.
Variants§
Core(CoreValueWithClassification)
Core value with classification
Native(NativeCoreValue)
Native rust value with DATEX representation
Implementations§
Source§impl Value
impl Value
Sourcepub fn native(value: impl DatexNative) -> Value
pub fn native(value: impl DatexNative) -> Value
Creates a new Value from a native value that implements the DatexNative trait.
pub fn native_boxed(value: Box<dyn DatexNative>) -> Value
pub fn core(inner: impl Into<CoreValueWithClassification>) -> Self
pub fn core_with_classification( inner: impl Into<CoreValue>, classification: ValueClassification, ) -> Self
pub fn is_collection_value(&self) -> bool
pub fn null() -> Self
pub fn uninitialized() -> Self
Sourcepub fn classification(
&self,
cache: &mut SharedReferencesCache,
) -> ValueClassification
pub fn classification( &self, cache: &mut SharedReferencesCache, ) -> ValueClassification
Returns the classification of the value, which includes its entity type, impls, and tag.
Sourcepub fn unresolved_classification(&self) -> UnresolvedValueClassification
pub fn unresolved_classification(&self) -> UnresolvedValueClassification
Returns the unresolved classification of the value, which includes its entity type, impls, and tag.
In contrast to classification, this method does not require a mutable reference to a cache
and only returns an address for an entity type if it is present, without resolving it to a full type.
pub fn new(inner: impl ConvertValue) -> Self
pub fn is_uninitialized(&self) -> bool
Sourcepub fn without_local_observers(self) -> Value
pub fn without_local_observers(self) -> Value
Strips any local observers from the given value container. This method should be called when a value is moved from its [SharedContainer] parent.
Sourcepub fn boxed(value: impl Into<ValueContainer>) -> Self
pub fn boxed(value: impl Into<ValueContainer>) -> Self
Creates a new Value representing a boxed value. This can be used to wrap a ValueContainer directly into a local Value, e.g. for #Tagged(shared X) or (X | null) | null
pub fn unbox(self) -> Result<ValueContainer, Value>
Sourcepub fn try_as<T>(&self) -> Option<&T>where
T: ConvertValue + ?Sized,
pub fn try_as<T>(&self) -> Option<&T>where
T: ConvertValue + ?Sized,
Tries to get a borrow of the current value as the specified type. Does not perform any type conversion.
pub fn try_as_mut<T>(&mut self) -> Option<&mut T>where
T: ConvertValue,
Sourcepub fn try_as_str(&self) -> Option<&str>
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 Value::try_as::
Sourcepub fn try_into_value<T>(self) -> Result<T, Value>where
T: ConvertValue,
pub fn try_into_value<T>(self) -> Result<T, Value>where
T: ConvertValue,
Tries to convert the current value into the specific specified type. Does not perform any type conversion.
Sourcepub fn try_convert_into_value<T>(self) -> Result<T, ()>where
T: ConvertValue + FromParts,
pub fn try_convert_into_value<T>(self) -> Result<T, ()>where
T: ConvertValue + FromParts,
Tries to convert the current value into the specific specified type. Performs a cast between native and core values if necessary, e.g. converting a CoreValue::Map into a native rust struct.
Sourcepub fn try_as_core_value(&self) -> Option<&CoreValue>
pub fn try_as_core_value(&self) -> Option<&CoreValue>
Tries to get a reference to the inner CoreValue if the Value is a Value::Core variant.
Sourcepub fn try_as_core_value_mut(&mut self) -> Option<&mut CoreValue>
pub fn try_as_core_value_mut(&mut self) -> Option<&mut CoreValue>
Tries to get a mutable reference to the inner CoreValue if the Value is a Value::Core variant.
Sourcepub fn try_into_core_value(self) -> Result<CoreValue, Value>
pub fn try_into_core_value(self) -> Result<CoreValue, Value>
Tries to convert the current value into a CoreValue if the Value is a Value::Core variant.
Source§impl Value
impl Value
pub fn callable( name: Option<String>, signature: CallableTypeDefinition, body: CallableBody, creator: Endpoint, ) -> Self
pub fn is_null(&self) -> bool
Sourcepub fn downcast_native<T: DatexNative>(self) -> Option<Box<T>>
pub fn downcast_native<T: DatexNative>(self) -> Option<Box<T>>
Tries to downcast the CoreValue to a native value of type T.
This method will return Some(Box
Sourcepub fn downcast_native_ref<T: DatexNative>(&self) -> Option<&T>
pub fn downcast_native_ref<T: DatexNative>(&self) -> Option<&T>
Tries to downcast the CoreValue to a reference of a native value of type T. This method will return Some(&T) if the CoreValue is a Native variant and the underlying value can be downcast to T.
Sourcepub fn downcast_native_mut<T: DatexNative>(&mut self) -> Option<&mut T>
pub fn downcast_native_mut<T: DatexNative>(&mut self) -> Option<&mut T>
Tries to downcast the CoreValue to a mutable reference of a native value of type T. This method will return Some(&mut T) if the CoreValue is a Native variant and the underlying value can be downcast to T.
Sourcepub fn try_get_property(
&self,
key: &ValueContainer,
) -> Result<BorrowedValueContainer<'_>, AccessError>
pub fn try_get_property( &self, key: &ValueContainer, ) -> Result<BorrowedValueContainer<'_>, AccessError>
Gets a property on the value if applicable (e.g. for map and structs)
pub fn try_get_property_mut( &mut self, key: &ValueContainer, ) -> Result<BorrowedValueContainerMut<'_>, AccessError>
Sourcepub fn actual_type(&self) -> TypeDefinition
pub fn actual_type(&self) -> TypeDefinition
Returns the actual current TypeDefinition of the value
Trait Implementations§
Source§impl<T> AddAssign<T> for Value
impl<T> AddAssign<T> for Value
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+= operation. Read moreSource§impl Apply for Value
impl Apply for Value
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§impl Classification for Value
impl Classification for Value
Source§fn entity_type(&self, cache: &mut SharedReferencesCache) -> Option<EntityType>
fn entity_type(&self, cache: &mut SharedReferencesCache) -> Option<EntityType>
Source§fn entity_type_address(&self) -> Option<PointerAddress>
fn entity_type_address(&self) -> Option<PointerAddress>
Source§fn tag(&self) -> Option<ValueTag>
fn tag(&self) -> Option<ValueTag>
Source§fn impls(&self) -> Vec<PointerAddress>
fn impls(&self) -> Vec<PointerAddress>
Source§fn classification(
&self,
cache: &mut SharedReferencesCache,
) -> ValueClassification
fn classification( &self, cache: &mut SharedReferencesCache, ) -> ValueClassification
Source§fn unresolved_classification(&self) -> UnresolvedValueClassification
fn unresolved_classification(&self) -> UnresolvedValueClassification
Source§impl ConvertValueContainer for Value
impl ConvertValueContainer for Value
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, ()>
Source§impl DatexHash for Value
impl DatexHash for Value
fn datex_hash(&self, state: &mut dyn Hasher)
fn datex_hash_default(&self) -> u64
Source§impl DatexNative for Value
impl DatexNative for Value
Source§impl DatexNativeOps for Value
impl DatexNativeOps for Value
fn add_native(&self, _rhs: &dyn DatexNative) -> Option<Box<dyn DatexNative>>
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'de> DeserializeWithSerdeContext<'de> for Value
impl<'de> DeserializeWithSerdeContext<'de> for Value
fn deserialize_with_ctx<D>(
ctx: &SerdeContext<'_>,
deserializer: D,
) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for Value
Source§impl<'a> From<&'a Value> for BorrowedValue<'a>
impl<'a> From<&'a Value> for BorrowedValue<'a>
Source§impl<'a> From<&'a Value> for BorrowedValueContainer<'a>
impl<'a> From<&'a Value> for BorrowedValueContainer<'a>
Source§impl<'a> From<&'a mut Value> for BorrowedValue<'a>
impl<'a> From<&'a mut Value> for BorrowedValue<'a>
Source§impl<T: ConvertValue> From<T> for Value
impl<T: ConvertValue> From<T> for Value
Source§impl From<Value> for InstructionInput
impl From<Value> for InstructionInput
Source§impl FromParts for Value
impl FromParts for Value
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,
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,
Source§impl GetCoreLibTypeId for Value
impl GetCoreLibTypeId for Value
fn core_lib_type_id(&self) -> CoreLibTypeId
Source§impl GetDatexType for Value
impl GetDatexType for Value
fn datex_type(_context: &mut SharedReferencesCache) -> Type
Source§impl HasPartsKind for Value
impl HasPartsKind for Value
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§impl InternalMutabilityUpdateHandler for Value
impl InternalMutabilityUpdateHandler for Value
fn set_update_callback_data(&mut self, observe_data: Option<UpdateCallbackData>)
Source§fn set_child_update_callback_data(
&self,
child_key: impl Into<ValueContainer>,
child_value: &mut Value,
)
fn set_child_update_callback_data( &self, child_key: impl Into<ValueContainer>, child_value: &mut Value, )
Source§fn set_child_update_callback_data_if_local(
&self,
child_key: &(impl Into<ValueContainer> + Clone),
child_value: &mut ValueContainer,
)
fn set_child_update_callback_data_if_local( &self, child_key: &(impl Into<ValueContainer> + Clone), child_value: &mut ValueContainer, )
Source§fn maybe_trigger_update_callback(
&self,
source_id: Option<TransceiverId>,
update_operation_generator: impl FnOnce() -> UpdateOperation,
)
fn maybe_trigger_update_callback( &self, source_id: Option<TransceiverId>, update_operation_generator: impl FnOnce() -> UpdateOperation, )
Source§impl IntoParts for Value
impl IntoParts for Value
Source§fn try_into_map_parts<'a>(self: Box<Self>) -> Result<Map, ()>where
Self: 'a,
fn try_into_map_parts<'a>(self: Box<Self>) -> Result<Map, ()>where
Self: 'a,
parts_kind()
and checking if it returns PartsKind::Map.Source§fn try_into_list_parts<'a>(self: Box<Self>) -> Result<List, ()>where
Self: 'a,
fn try_into_list_parts<'a>(self: Box<Self>) -> Result<List, ()>where
Self: 'a,
parts_kind()
and checking if it returns PartsKind::List.Source§fn try_into_single_value<'a>(self: Box<Self>) -> Result<ValueContainer, ()>where
Self: 'a,
fn try_into_single_value<'a>(self: Box<Self>) -> Result<ValueContainer, ()>where
Self: 'a,
parts_kind()
and checking if it returns PartsKind::SingleValue.Source§impl IterParts for Value
impl IterParts for Value
fn iter_list_parts<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = BorrowedValueContainer<'a>> + 'a>>
fn iter_list_parts_mut<'a>( &'a mut self, ) -> Option<Box<dyn Iterator<Item = BorrowedValueContainerMut<'a>> + 'a>>
fn iter_map_parts<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = (BorrowedValueContainer<'a>, BorrowedValueContainer<'a>)> + 'a>>
fn iter_map_parts_mut<'a>( &'a mut self, ) -> Option<Box<dyn Iterator<Item = (BorrowedValueContainer<'a>, BorrowedValueContainerMut<'a>)> + 'a>>
fn iter_parts<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = BorrowedValueContainer<'a>> + 'a>>
Source§impl LocalChildPathResolver for Value
impl LocalChildPathResolver for Value
fn resolve_child( &mut self, _key: &ValueContainer, ) -> Result<&mut ValueContainer, UpdateError>
fn resolve_value_for_path( &mut self, first: &ValueContainer, remaining_path: &[ValueContainer], ) -> Result<&mut Value, UpdateError>
Source§impl SerializeWithSerdeContext for Value
Serialization for Value.
impl SerializeWithSerdeContext for Value
Serialization for Value.
fn serialize_with_ctx<S>(
&self,
ctx: &SerdeContext<'_>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Source§impl StructuralEq for Value
Two values are structurally equal, if their inner values are structurally equal, regardless
of the actual_type of the values
impl StructuralEq for Value
Two values are structurally equal, if their inner values are structurally equal, regardless of the actual_type of the values
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
Source§impl ToInstructions for Value
impl ToInstructions for Value
fn to_instructions<'a>( &'a self, visitor: &'a mut dyn ValueVisitor, cache: &'a mut SharedReferencesCache, ) -> Box<dyn Iterator<Item = Instruction> + 'a>
Source§impl<'a, T> TryFrom<&'a Value> for Option<&'a T>where
T: DatexNativeBase + ConvertValue + 'static,
impl<'a, T> TryFrom<&'a Value> for Option<&'a T>where
T: DatexNativeBase + ConvertValue + 'static,
Source§impl<'a, T> TryFrom<&'a mut Value> for Option<&'a mut T>where
T: DatexNativeBase + ConvertValue + 'static,
impl<'a, T> TryFrom<&'a mut Value> for Option<&'a mut T>where
T: DatexNativeBase + ConvertValue + 'static,
Source§impl<'a> TryFrom<&'a mut Value> for BorrowedValueMut<'a>
impl<'a> TryFrom<&'a mut Value> for BorrowedValueMut<'a>
Source§impl UpdateCallbackDataAccess for Value
impl UpdateCallbackDataAccess for Value
fn get_update_callback_data(&self) -> Option<&UpdateCallbackData>
Source§impl UpdateHandlerImpl for Value
impl UpdateHandlerImpl for Value
Source§fn try_update(
&mut self,
operation: UpdateOperation,
source_id: Option<TransceiverId>,
cache: &RefCell<SharedReferencesCache>,
) -> UpdateResult
fn try_update( &mut self, operation: UpdateOperation, source_id: Option<TransceiverId>, cache: &RefCell<SharedReferencesCache>, ) -> UpdateResult
Tries to update the value with the given operation. If a path first needs to be resolved, use Value::try_update_collapsed_local_inner
fn try_set_entry( &mut self, _data: SetEntryUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<Option<ValueContainer>, UpdateError>
fn try_delete_entry( &mut self, _data: DeleteEntryUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>
fn try_append_entry( &mut self, _data: AppendEntryUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_clear( &mut self, _cache: &RefCell<SharedReferencesCache>, ) -> Result<ValueContainer, UpdateError>
fn try_list_splice( &mut self, _data: ListSpliceUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<Vec<ValueContainer>, UpdateError>
fn try_increment( &mut self, _data: IncrementUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_decrement( &mut self, _data: DecrementUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
fn try_replace( &mut self, _data: ReplaceUpdateData, _cache: &RefCell<SharedReferencesCache>, ) -> Result<(), UpdateError>
Source§impl ValueAccess for Value
impl ValueAccess for Value
Source§fn try_get_property(
&self,
key: &ValueContainer,
) -> Result<BorrowedValueContainer<'_>, AccessError>
fn try_get_property( &self, key: &ValueContainer, ) -> Result<BorrowedValueContainer<'_>, AccessError>
Source§fn try_get_property_mut(
&mut self,
key: &ValueContainer,
) -> Result<BorrowedValueContainerMut<'_>, AccessError>
fn try_get_property_mut( &mut self, key: &ValueContainer, ) -> Result<BorrowedValueContainerMut<'_>, AccessError>
Auto Trait Implementations§
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl !UnwindSafe for Value
impl Forget for Value
impl Freeze for Value
impl Move for Value
impl Unpin for Value
impl UnsafeUnpin for Value
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,
impl<T> DatexNativeBase for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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