Skip to main content

Object

Trait Object 

Source
pub trait Object: Send + Sync {
    // Required methods
    fn display(&self, _cx: &mut Cx) -> Result<String>;
    fn as_any(&self) -> &dyn Any;

    // Provided methods
    fn header(&self) -> &ObjectHeader { ... }
    fn op(&self, _key: &OpKey) -> Option<&dyn Op> { ... }
    fn claims(
        &self,
        _cx: &mut Cx,
        _pattern: &ClaimPattern,
        _sink: &mut dyn ClaimSink,
    ) -> Result<()> { ... }
    fn snapshot(&self, _cx: &mut Cx) -> Result<Option<Datum>> { ... }
}
Expand description

Base protocol implemented by every runtime value.

SIM uses object-style protocol views instead of a closed value enum for extensible runtime behavior. The root trait stays small: behavior is exposed through headers, operations, claims, snapshots, display, and Rust downcasting.

Required Methods§

Source

fn display(&self, _cx: &mut Cx) -> Result<String>

Render the object as a human-readable display string.

Source

fn as_any(&self) -> &dyn Any

Expose the object for Rust downcasting.

Provided Methods§

Source

fn header(&self) -> &ObjectHeader

Identity and trust header for the object; defaults to the shared anonymous header.

Source

fn op(&self, _key: &OpKey) -> Option<&dyn Op>

Resolve the operation registered under key, if any.

Source

fn claims( &self, _cx: &mut Cx, _pattern: &ClaimPattern, _sink: &mut dyn ClaimSink, ) -> Result<()>

Emit the object’s claims matching pattern into sink.

Source

fn snapshot(&self, _cx: &mut Cx) -> Result<Option<Datum>>

Optional content-addressable snapshot of the object’s state.

Implementations§

Source§

impl dyn Object

Source

pub fn downcast_ref<T: Any>(&self) -> Option<&T>

Downcast the object to a concrete type T, if it is that type.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§