pub struct MutableRuntimeTable<P> { /* private fields */ }Expand description
A mutable table keyed by arbitrary runtime values.
Unlike MutableTable, this table does not implement
the kernel symbol-keyed table contract. It is the shared substrate for guest
language hash/map/table values whose keys can be booleans, numbers, strings,
symbols, or object identities. Writes require
standard_mutate_capability; reads are always allowed.
Implementations§
Source§impl<P: RuntimeKeyPolicy> MutableRuntimeTable<P>
impl<P: RuntimeKeyPolicy> MutableRuntimeTable<P>
Sourcepub fn with_entries(
cx: &mut Cx,
policy: P,
entries: Vec<(Value, Value)>,
) -> Result<Self>
pub fn with_entries( cx: &mut Cx, policy: P, entries: Vec<(Value, Value)>, ) -> Result<Self>
Creates a runtime-keyed table seeded with entries.
Seeding is construction, not mutation, so it does not require the mutate capability. Later duplicate keys replace earlier entries.
Sourcepub fn get(&self, cx: &mut Cx, key: &Value) -> Result<Option<Value>>
pub fn get(&self, cx: &mut Cx, key: &Value) -> Result<Option<Value>>
Reads a value using the configured key policy.
Sourcepub fn get_runtime_key(&self, key: &RuntimeKey) -> Result<Option<Value>>
pub fn get_runtime_key(&self, key: &RuntimeKey) -> Result<Option<Value>>
Reads a value using an already-derived runtime key.
Sourcepub fn set(&self, cx: &mut Cx, key: Value, value: Value) -> Result<()>
pub fn set(&self, cx: &mut Cx, key: Value, value: Value) -> Result<()>
Writes a value using the configured key policy.
Sourcepub fn set_runtime_key(
&self,
cx: &mut Cx,
key: RuntimeKey,
value: Value,
) -> Result<()>
pub fn set_runtime_key( &self, cx: &mut Cx, key: RuntimeKey, value: Value, ) -> Result<()>
Writes a value using an already-derived runtime key.
Sourcepub fn del(&self, cx: &mut Cx, key: &Value) -> Result<Option<Value>>
pub fn del(&self, cx: &mut Cx, key: &Value) -> Result<Option<Value>>
Deletes a value using the configured key policy.
Sourcepub fn del_runtime_key(
&self,
cx: &mut Cx,
key: &RuntimeKey,
) -> Result<Option<Value>>
pub fn del_runtime_key( &self, cx: &mut Cx, key: &RuntimeKey, ) -> Result<Option<Value>>
Deletes a value using an already-derived runtime key.
Sourcepub fn entries_in_key_order(&self) -> Result<Vec<(RuntimeKey, Value)>>
pub fn entries_in_key_order(&self) -> Result<Vec<(RuntimeKey, Value)>>
Returns entries in deterministic key order.
Trait Implementations§
Source§impl<P: RuntimeKeyPolicy + 'static> Object for MutableRuntimeTable<P>
impl<P: RuntimeKeyPolicy + 'static> Object for MutableRuntimeTable<P>
Source§fn display(&self, _cx: &mut Cx) -> Result<String>
fn display(&self, _cx: &mut Cx) -> Result<String>
Source§fn header(&self) -> &ObjectHeader
fn header(&self) -> &ObjectHeader
Source§fn op(&self, _key: &OpKey) -> Option<&dyn Op>
fn op(&self, _key: &OpKey) -> Option<&dyn Op>
key, if any.