pub enum Map {
Dynamic(IndexMap<ValueContainer, ValueContainer, RandomState>),
Structural(Vec<(ValueContainer, ValueContainer)>),
StructuralWithStringKeys(Vec<(String, ValueContainer)>),
}Variants§
Dynamic(IndexMap<ValueContainer, ValueContainer, RandomState>)
Structural(Vec<(ValueContainer, ValueContainer)>)
StructuralWithStringKeys(Vec<(String, ValueContainer)>)
Implementations§
Source§impl Map
impl Map
pub fn new( entries: IndexMap<ValueContainer, ValueContainer, RandomState>, ) -> Self
pub fn new_structural_with_string_keys( entries: Vec<(String, ValueContainer)>, ) -> Self
pub fn is_structural(&self) -> bool
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get<'a>(
&self,
key: impl Into<BorrowedValueKey<'a>>,
) -> Result<&ValueContainer, KeyNotFoundError>
pub fn get<'a>( &self, key: impl Into<BorrowedValueKey<'a>>, ) -> Result<&ValueContainer, KeyNotFoundError>
Gets a value in the map by reference. Returns None if the key is not found.
Sourcepub fn has<'a>(&self, key: impl Into<BorrowedValueKey<'a>>) -> bool
pub fn has<'a>(&self, key: impl Into<BorrowedValueKey<'a>>) -> bool
Checks if the map contains the given key.
Sourcepub fn ensure_only_properties(
&self,
allowed: &[&str],
) -> Result<(), UnexpectedPropertyError>
pub fn ensure_only_properties( &self, allowed: &[&str], ) -> Result<(), UnexpectedPropertyError>
Ensures that the map only contains the given allowed keys, returning an error if any unexpected keys are found. This should only be called on structural maps, as it relies on the assumption that the map will not be modified after construction.
Sourcepub fn try_delete<'a>(
&mut self,
key: impl Into<BorrowedValueKey<'a>>,
) -> Result<ValueContainer, MapAccessError>
pub fn try_delete<'a>( &mut self, key: impl Into<BorrowedValueKey<'a>>, ) -> Result<ValueContainer, MapAccessError>
Removes a key from the map, returning the value if it existed.
Sourcepub unsafe fn try_delete_unsafe<'a>(
&mut self,
key: impl Into<BorrowedValueKey<'a>>,
) -> Result<ValueContainer, KeyNotFoundError>
pub unsafe fn try_delete_unsafe<'a>( &mut self, key: impl Into<BorrowedValueKey<'a>>, ) -> Result<ValueContainer, KeyNotFoundError>
Removes a key from the map, returning the value if it existed. Also works for structural maps, but creates a map that no longer matches the assumed type. The map should no longer be used after this operation.
Sourcepub fn try_clear_inner(&mut self) -> Result<(), MapAccessError>
pub fn try_clear_inner(&mut self) -> Result<(), MapAccessError>
Clears all entries in the map, returning an error if the map is not dynamic.
Trait Implementations§
Source§impl<'a> ChildIterator<'a> for Map
impl<'a> ChildIterator<'a> for Map
fn iter_children(&'a self) -> impl Iterator<Item = &'a ValueContainer> + 'a
Source§impl DatexProxyTypes for Map
impl DatexProxyTypes for Map
fn datex_type(_memory: &mut SharedReferencesCache) -> Type
impl DatexValueProxy for Map
Source§impl DatexValueProxyDeserialize for Map
impl DatexValueProxyDeserialize for Map
fn try_from_value(value: Value) -> Result<Self, TryFromDatexValueError>
fn try_from_map_property( value: Result<Value, KeyNotFoundError>, ) -> Result<Self, TryFromDatexValueError>
Source§impl DatexValueProxySerialize for Map
impl DatexValueProxySerialize for Map
fn try_to_value(self) -> Result<Value, TryToDatexValueError>
impl Eq for Map
Source§impl<K, V> From<IndexMap<K, V, RandomState>> for Map
impl<K, V> From<IndexMap<K, V, RandomState>> for Map
Source§fn from(map: IndexMap<K, V, RandomState>) -> Self
fn from(map: IndexMap<K, V, RandomState>) -> Self
Source§impl From<Vec<(ValueContainer, ValueContainer)>> for Map
impl From<Vec<(ValueContainer, ValueContainer)>> for Map
Source§fn from(vec: Vec<(ValueContainer, ValueContainer)>) -> Self
fn from(vec: Vec<(ValueContainer, ValueContainer)>) -> Self
Create a dynamic map from a vector of value containers.
Source§impl<K, V> FromIterator<(K, V)> for Map
impl<K, V> FromIterator<(K, V)> for Map
Source§impl IntoIterator for Map
impl IntoIterator for Map
Source§impl<'a> IntoIterator for &'a mut Map
impl<'a> IntoIterator for &'a mut Map
Source§type Item = (BorrowedMapKey<'a>, &'a mut ValueContainer)
type Item = (BorrowedMapKey<'a>, &'a mut ValueContainer)
Source§type IntoIter = MapMutIterator<'a>
type IntoIter = MapMutIterator<'a>
Source§impl StructuralEq for Map
impl StructuralEq for Map
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
impl StructuralPartialEq for Map
Source§impl UpdateHandler for Map
impl UpdateHandler for Map
fn try_set_entry( &mut self, data: SetEntryUpdateData, _source_id: TransceiverId, ) -> Result<(), UpdateError>
fn try_delete_entry( &mut self, data: DeleteEntryUpdateData, _source_id: TransceiverId, ) -> Result<ValueContainer, UpdateError>
fn try_append_entry( &mut self, _data: AppendEntryUpdateData, _source_id: TransceiverId, ) -> Result<(), UpdateError>
fn try_clear(&mut self, _source_id: TransceiverId) -> Result<(), UpdateError>
fn try_list_splice( &mut self, _data: ListSpliceUpdateData, _source_id: TransceiverId, ) -> Result<Vec<ValueContainer>, UpdateError>
fn update(&mut self, update: Update) -> UpdateResult
fn try_replace( &mut self, _data: ReplaceUpdateData, _source_id: TransceiverId, ) -> Result<ValueContainer, UpdateError>
Auto Trait Implementations§
impl !RefUnwindSafe for Map
impl !Send for Map
impl !Sync for Map
impl !UnwindSafe for Map
impl Freeze for Map
impl Unpin for Map
impl UnsafeUnpin for Map
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> DatexValueContainerProxy for Twhere
T: DatexValueProxy,
Source§impl<T> DatexValueContainerProxyDeserialize for Twhere
T: DatexValueProxyDeserialize,
impl<T> DatexValueContainerProxyDeserialize for Twhere
T: DatexValueProxyDeserialize,
fn try_from_value_container( value: ValueContainer, ) -> Result<T, TryFromDatexValueError>
fn try_from_map_property( value: Result<ValueContainer, KeyNotFoundError>, ) -> Result<T, TryFromDatexValueError>
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§impl<T> DatexValueContainerProxyInfallibleSerialize for Twhere
T: DatexValueProxyInfallibleSerialize,
impl<T> DatexValueContainerProxyInfallibleSerialize for Twhere
T: DatexValueProxyInfallibleSerialize,
fn to_value_container(self) -> ValueContainer
Source§impl<T> DatexValueContainerProxySerialize for Twhere
T: DatexValueProxySerialize,
impl<T> DatexValueContainerProxySerialize for Twhere
T: DatexValueProxySerialize,
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> 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