pub trait Table: RuntimeObject {
Show 13 methods
// Required methods
fn backend_symbol(&self) -> Symbol;
fn get(&self, cx: &mut Cx, key: Symbol) -> Result<Value>;
fn set(&self, cx: &mut Cx, key: Symbol, value: Value) -> Result<()>;
fn has(&self, cx: &mut Cx, key: Symbol) -> Result<bool>;
fn del(&self, cx: &mut Cx, key: Symbol) -> Result<Value>;
fn keys(&self, cx: &mut Cx) -> Result<Vec<Symbol>>;
fn entries(&self, cx: &mut Cx) -> Result<Vec<(Symbol, Value)>>;
fn len(&self, cx: &mut Cx) -> Result<usize>;
fn clear(&self, cx: &mut Cx) -> Result<()>;
// Provided methods
fn is_empty(&self, cx: &mut Cx) -> Result<bool> { ... }
fn compare_exchange(
&self,
_cx: &mut Cx,
_key: Symbol,
_expected: TableExpected,
_replacement: TableReplacement,
) -> Result<TableCompareExchange> { ... }
fn as_table_expr(&self, cx: &mut Cx) -> Result<Expr> { ... }
fn table_eq(&self, cx: &mut Cx, other: &dyn Table) -> Result<bool> { ... }
}Expand description
Universal map surface. Keys are symbols; values are runtime values.
Required Methods§
Sourcefn backend_symbol(&self) -> Symbol
fn backend_symbol(&self) -> Symbol
Symbol identifying the backend representation.
Sourcefn get(&self, cx: &mut Cx, key: Symbol) -> Result<Value>
fn get(&self, cx: &mut Cx, key: Symbol) -> Result<Value>
Looks up key, returning nil when absent.
Sourcefn set(&self, cx: &mut Cx, key: Symbol, value: Value) -> Result<()>
fn set(&self, cx: &mut Cx, key: Symbol, value: Value) -> Result<()>
Inserts or replaces the value for key.
Sourcefn del(&self, cx: &mut Cx, key: Symbol) -> Result<Value>
fn del(&self, cx: &mut Cx, key: Symbol) -> Result<Value>
Removes key, returning its prior value or nil.
Provided Methods§
Sourcefn compare_exchange(
&self,
_cx: &mut Cx,
_key: Symbol,
_expected: TableExpected,
_replacement: TableReplacement,
) -> Result<TableCompareExchange>
fn compare_exchange( &self, _cx: &mut Cx, _key: Symbol, _expected: TableExpected, _replacement: TableReplacement, ) -> Result<TableCompareExchange>
Atomically replaces key iff its state equals expected.
Equality is canonical semantic Expr equality. Implementations must
establish one linearization point or honestly report unsupported.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".