Skip to main content

Object

Trait Object 

Source
pub trait Object<'a>: Debug {
    // Required method
    fn type_name(&self) -> &'static str;

    // Provided methods
    fn as_any(&self) -> Option<&dyn Any> { ... }
    fn underlying(&self) -> Option<&Value<'a>> { ... }
    fn field(&self, _name: &str) -> Option<Value<'a>> { ... }
    fn method(
        &self,
        _name: &str,
        _args: Vec<Arg<'a, '_>>,
    ) -> Option<Result<Value<'a>>> { ... }
    fn call(&self, _args: &[Value<'a>]) -> Option<Result<Value<'a>>> { ... }
    fn is_callable(&self) -> bool { ... }
    fn display(&self) -> Result<String> { ... }
    fn display_text(&self) -> Option<&str> { ... }
    fn is_trusted_html(&self) -> bool { ... }
    fn entries(&self, _limit: usize) -> Result<Vec<(Value<'a>, Value<'a>)>> { ... }
    fn json_kind(&self) -> JsonKind<'_> { ... }
}
Expand description

A per-render engine object such as a slot, closure, date or attribute bag.

Required Methods§

Source

fn type_name(&self) -> &'static str

Stable engine type name used in diagnostics and dispatch.

Provided Methods§

Source

fn as_any(&self) -> Option<&dyn Any>

Exposes a static object for native downcasting when supported.

Source

fn underlying(&self) -> Option<&Value<'a>>

Borrows the value represented by a transparent display wrapper, if present.

Source

fn field(&self, _name: &str) -> Option<Value<'a>>

Reads an exposed named field.

Source

fn method( &self, _name: &str, _args: Vec<Arg<'a, '_>>, ) -> Option<Result<Value<'a>>>

Calls an exposed method.

Source

fn call(&self, _args: &[Value<'a>]) -> Option<Result<Value<'a>>>

Calls a callable object, if applicable.

Source

fn is_callable(&self) -> bool

Indicates whether this object can be passed as a closure.

Source

fn display(&self) -> Result<String>

Returns the printable representation, if supported.

Source

fn display_text(&self) -> Option<&str>

Borrows the printable representation when it is already stored as text.

If supplied, this must match the text returned by display.

Source

fn is_trusted_html(&self) -> bool

Indicates that the object’s printable representation is trusted HTML.

Source

fn entries(&self, _limit: usize) -> Result<Vec<(Value<'a>, Value<'a>)>>

Expands an iterable object up to the supplied element limit.

Source

fn json_kind(&self) -> JsonKind<'_>

Borrows the object’s JSON representation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§