Struct koto_runtime::KMap
source · pub struct KMap { /* private fields */ }
Implementations§
source§impl KMap
impl KMap
sourcepub fn with_type(type_name: &str) -> Self
pub fn with_type(type_name: &str) -> Self
Creates an empty KMap, with a MetaMap containing the given @type string
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty KMap with the given capacity
sourcepub fn with_contents(data: ValueMap, meta: Option<MetaMap>) -> Self
pub fn with_contents(data: ValueMap, meta: Option<MetaMap>) -> Self
Creates a KMap initialized with the provided data and meta map
sourcepub fn from_data_and_meta_maps(data: &Self, meta: &Self) -> Self
pub fn from_data_and_meta_maps(data: &Self, meta: &Self) -> Self
Makes a KMap taking the data map from the first arg, and the meta map from the second
sourcepub fn meta_map(&self) -> Option<&PtrMut<MetaMap>>
pub fn meta_map(&self) -> Option<&PtrMut<MetaMap>>
Provides a reference to the KMap’s meta map
This is returned as a reference to the meta map’s PtrMut to allow for cloning.
sourcepub fn set_meta_map(&mut self, meta: Option<PtrMut<MetaMap>>)
pub fn set_meta_map(&mut self, meta: Option<PtrMut<MetaMap>>)
Sets the KMap’s meta map
Note that this change isn’t shared with maps that share the same data.
sourcepub fn contains_meta_key(&self, key: &MetaKey) -> bool
pub fn contains_meta_key(&self, key: &MetaKey) -> bool
Returns true if the meta map contains an entry with the given key
sourcepub fn get<K>(&self, key: &K) -> Option<KValue>
pub fn get<K>(&self, key: &K) -> Option<KValue>
Returns a clone of the data value corresponding to the given key
sourcepub fn get_meta_value(&self, key: &MetaKey) -> Option<KValue>
pub fn get_meta_value(&self, key: &MetaKey) -> Option<KValue>
Returns a clone of the meta value corresponding to the given key
sourcepub fn insert(&self, key: impl Into<ValueKey>, value: impl Into<KValue>)
pub fn insert(&self, key: impl Into<ValueKey>, value: impl Into<KValue>)
Insert an entry into the KMap’s data
sourcepub fn insert_meta(&mut self, key: MetaKey, value: KValue)
pub fn insert_meta(&mut self, key: MetaKey, value: KValue)
Inserts a value into the meta map, initializing the meta map if it doesn’t yet exist
sourcepub fn add_fn(&self, id: &str, f: impl KotoFunction)
pub fn add_fn(&self, id: &str, f: impl KotoFunction)
Adds a function to the KMap’s data map
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of entries in the KMap’s data map
Note that this doesn’t include entries in the meta map.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the KMap’s data map contains no entries
Note that this doesn’t take entries in the meta map into account.
sourcepub fn is_same_instance(&self, other: &Self) -> bool
pub fn is_same_instance(&self, other: &Self) -> bool
Returns true if the provided KMap occupies the same memory address
sourcepub fn display(&self, ctx: &mut DisplayContext<'_>) -> Result<()>
pub fn display(&self, ctx: &mut DisplayContext<'_>) -> Result<()>
Renders the map to the provided display context
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KMap
impl !RefUnwindSafe for KMap
impl Send for KMap
impl Sync for KMap
impl Unpin for KMap
impl !UnwindSafe for KMap
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.