Skip to main content

Class

Trait Class 

Source
pub trait Class: Callable {
    // Required methods
    fn id(&self) -> ClassId;
    fn symbol(&self) -> Symbol;
    fn constructor_shape(&self, cx: &mut Cx) -> Result<ShapeRef>;
    fn instance_shape(&self, cx: &mut Cx) -> Result<ShapeRef>;
    fn read_constructor(
        &self,
        cx: &mut Cx,
    ) -> Result<Option<ReadConstructorRef>>;
    fn members(&self, cx: &mut Cx) -> Result<TableRef>;

    // Provided methods
    fn parents(&self, _cx: &mut Cx) -> Result<Vec<ClassRef>> { ... }
    fn is_subclass_of(&self, cx: &mut Cx, expected: ClassRef) -> Result<bool>
       where Self: Sized { ... }
}
Expand description

Runtime protocol for class objects.

Classes are callable constructor values with stable identity, shape metadata, read-constructor support, and browseable members.

Required Methods§

Source

fn id(&self) -> ClassId

Stable identity of the class.

Source

fn symbol(&self) -> Symbol

Display symbol naming the class.

Source

fn constructor_shape(&self, cx: &mut Cx) -> Result<ShapeRef>

Shape describing the arguments accepted by the constructor.

Source

fn instance_shape(&self, cx: &mut Cx) -> Result<ShapeRef>

Shape describing instances produced by the class.

Source

fn read_constructor(&self, cx: &mut Cx) -> Result<Option<ReadConstructorRef>>

Optional read-constructor for decoding instances from data forms.

Source

fn members(&self, cx: &mut Cx) -> Result<TableRef>

Browseable member table of the class.

Provided Methods§

Source

fn parents(&self, _cx: &mut Cx) -> Result<Vec<ClassRef>>

Direct parent classes; the default reports no parents.

Source

fn is_subclass_of(&self, cx: &mut Cx, expected: ClassRef) -> Result<bool>
where Self: Sized,

Whether this class is expected or transitively descends from it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§