Skip to main content

CustomObject

Trait CustomObject 

Source
pub trait CustomObject:
    ObjectView
    + Debug
    + Send
    + Sync {
    // Required methods
    fn as_json(&self) -> Value;
    fn as_any(&self) -> &dyn Any;
}
Expand description

A consumer-supplied object type that the matcher can view uniformly.

Blanket-implemented for any ObjectView that is also Serialize, so a consumer only writes an ObjectView impl. as_json backs serialization and equality; as_any enables downcasting back to the concrete type.

Required Methods§

Source

fn as_json(&self) -> Value

The object serialized as a JSON value.

Source

fn as_any(&self) -> &dyn Any

The object as &dyn Any, for downcasting to the concrete type.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T> CustomObject for T
where T: ObjectView + Serialize + Debug + Send + Sync + 'static,