Skip to main content

ObjectCompat

Trait ObjectCompat 

Source
pub trait ObjectCompat: Object {
Show 19 methods // Provided methods fn class(&self, cx: &mut Cx) -> Result<ClassRef> { ... } fn as_callable(&self) -> Option<&dyn Callable> { ... } fn as_class(&self) -> Option<&dyn Class> { ... } fn as_shape(&self) -> Option<&dyn Shape> { ... } fn as_object_encoder(&self) -> Option<&dyn ObjectEncode> { ... } fn as_read_constructor(&self) -> Option<&dyn ReadConstructor> { ... } fn as_number_domain(&self) -> Option<&dyn NumberDomain> { ... } fn as_number_value(&self) -> Option<&dyn NumberValue> { ... } fn as_eval_fabric(&self) -> Option<&dyn EvalFabric> { ... } fn as_stream(&self) -> Option<&dyn Stream> { ... } fn as_sequence(&self) -> Option<&dyn Sequence> { ... } fn as_thunk(&self) -> Option<&dyn Thunk> { ... } fn as_list(&self) -> Option<&dyn ListValue> { ... } fn as_table_impl(&self) -> Option<&dyn Table> { ... } fn as_dir(&self) -> Option<&dyn Dir> { ... } fn as_expr(&self, cx: &mut Cx) -> Result<Expr> { ... } fn truth(&self, _cx: &mut Cx) -> Result<bool> { ... } fn publish_shape_satisfaction_claims( &self, _cx: &mut Cx, _shape: &Ref, ) -> Result<bool> { ... } fn as_table(&self, cx: &mut Cx) -> Result<Value> { ... }
}
Expand description

Bridge that exposes typed protocol views (class, callable, shape, encoder, number, fabric, stream, and related accessors) for objects that do not resolve them through operations.

Callers should resolve operations, claims, refs, or snapshots instead of calling this trait. It is kept outside Object so the root object trait stays minimal while library objects expose this behavior through compatibility adapters.

Provided Methods§

Source

fn class(&self, cx: &mut Cx) -> Result<ClassRef>

Class object this value belongs to; defaults to nil.

Source

fn as_callable(&self) -> Option<&dyn Callable>

Callable view, if the object can be invoked.

Source

fn as_class(&self) -> Option<&dyn Class>

Class view, if the object is a class.

Source

fn as_shape(&self) -> Option<&dyn Shape>

Shape view, if the object is a shape.

Source

fn as_object_encoder(&self) -> Option<&dyn ObjectEncode>

Object-encoder view, if the object encodes other objects.

Source

fn as_read_constructor(&self) -> Option<&dyn ReadConstructor>

Read-constructor view, if the object decodes data forms.

Source

fn as_number_domain(&self) -> Option<&dyn NumberDomain>

Number-domain view, if the object is a number domain.

Source

fn as_number_value(&self) -> Option<&dyn NumberValue>

Number-value view, if the object is a domain number.

Source

fn as_eval_fabric(&self) -> Option<&dyn EvalFabric>

Eval-fabric view, if the object is a distributed eval surface.

Source

fn as_stream(&self) -> Option<&dyn Stream>

Stream view, if the object is a stream.

Source

fn as_sequence(&self) -> Option<&dyn Sequence>

Sequence view, if the object is a sequence.

Source

fn as_thunk(&self) -> Option<&dyn Thunk>

Thunk view, if the object is a deferred computation.

Source

fn as_list(&self) -> Option<&dyn ListValue>

List view, if the object is a list value.

Source

fn as_table_impl(&self) -> Option<&dyn Table>

Table-implementation view, if the object is a table.

Source

fn as_dir(&self) -> Option<&dyn Dir>

Directory view, if the object is a directory.

Source

fn as_expr(&self, cx: &mut Cx) -> Result<Expr>

Expression form of the object; defaults to an opaque extension node.

Source

fn truth(&self, _cx: &mut Cx) -> Result<bool>

Truthiness of the object; defaults to true.

Source

fn publish_shape_satisfaction_claims( &self, _cx: &mut Cx, _shape: &Ref, ) -> Result<bool>

Publish claims asserting that the object satisfies shape; returns whether any were published.

Source

fn as_table(&self, cx: &mut Cx) -> Result<Value>

Project the object into a table value; the default exposes its display.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§