pub trait ObjectPayload: ValidPayload {
    // Required method
    fn memory_layout(&self) -> &MemoryLayout;

    // Provided methods
    fn create_class(&self, ctx: &TypeContext) -> ClassRef { ... }
    fn runtime_class(&self, _ctx: &TypeContext) -> Option<ClassRef> { ... }
    fn get_property(
        &self,
        _ctx: &TypeContext,
        _ident: &Ident
    ) -> Option<ObjectRef> { ... }
    fn json_fmt(&self, buf: &mut Vec<JsonFormatComponent>) { ... }
}
Expand description

A trait for values that can be used as debris object payload

The private ValidPayload trait is auto-implemented

Required Methods§

source

fn memory_layout(&self) -> &MemoryLayout

Returns the memory layout of this specific object This method is usually only called once

Provided Methods§

source

fn create_class(&self, ctx: &TypeContext) -> ClassRef

The class specific to this object. Contains additionally to the class generics and the memory layout

Per default the default class of the object type

source

fn runtime_class(&self, _ctx: &TypeContext) -> Option<ClassRef>

Returns the class which the runtime encodable variant of this object would have. Used to determine the class passed into the promote method of objects.

source

fn get_property(&self, _ctx: &TypeContext, _ident: &Ident) -> Option<ObjectRef>

May be overwritten by distinct payloads which carry properties

source

fn json_fmt(&self, buf: &mut Vec<JsonFormatComponent>)

Converts this object into json components so it can be rendered in minecraft chat

Implementors§