Skip to main content

TableObject

Trait TableObject 

Source
pub trait TableObject:
    Debug
    + Any
    + Send
    + Sync
    + Serialize {
    // Required method
    fn as_any(&self) -> &dyn Any;
}
Expand description

Object-safe face of a runtime-registered table-section value.

Registered types must be owned ('static) because the dyn Any downcast path requires it. See the module docs for details.

Implemented automatically via the blanket impl for any T satisfying the supertraits; you do not need to write this by hand.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Borrow as &dyn Any so the caller can downcast to the concrete type.

Implementations§

Source§

impl dyn TableObject

Source

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

Downcast a registered table section to its concrete type T.

Works for Box<dyn TableObject> (it derefs to the trait object) under every feature configuration.

Source

pub fn is<T: Any>(&self) -> bool

true if the registered table section’s concrete type is T.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T> TableObject for T
where T: Debug + Any + Send + Sync + Serialize,

Available on crate feature serde only.