pub trait MetaObjectProtocol: Send + Sync {
// Required methods
fn raw_get(
&self,
cx: &mut Cx,
value: &Value,
key: &Value,
) -> Result<Option<Value>>;
fn get_meta(
&self,
cx: &mut Cx,
value: &Value,
slot: &Symbol,
) -> Result<Option<Value>>;
// Provided method
fn apply_meta(
&self,
cx: &mut Cx,
_receiver: &Value,
key: &Value,
_index_slot: &Symbol,
meta_value: &Value,
) -> Result<Option<Value>> { ... }
}Expand description
Language-neutral slot lookup for values with metadata-driven behavior.
Implementations provide raw indexed access plus a named meta-slot lookup. The slot names are supplied by language crates or other callers, so this protocol can model metatables, prototype parents, method dictionaries, and similar object layers without baking any one language’s names into dispatch.
Required Methods§
Provided Methods§
Sourcefn apply_meta(
&self,
cx: &mut Cx,
_receiver: &Value,
key: &Value,
_index_slot: &Symbol,
meta_value: &Value,
) -> Result<Option<Value>>
fn apply_meta( &self, cx: &mut Cx, _receiver: &Value, key: &Value, _index_slot: &Symbol, meta_value: &Value, ) -> Result<Option<Value>>
Applies a meta value to the original indexed read.
The default treats the meta value as another indexable object and looks
up key on it. Prototype languages can override this to recurse through
parent objects, while function-backed systems can override it to invoke
or otherwise interpret a callable meta value.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".