Skip to main content

ObjectCore

Trait ObjectCore 

Source
pub unsafe trait ObjectCore: Sized + 'static {
    type Parent;

    const TYPE_KEY: &'static str;
    const TYPE_DEPTH: i32;

    // Required methods
    fn type_index() -> i32;
    unsafe fn object_header_mut(this: &mut Self) -> &mut TVMFFIObject;
}
Expand description

The native representation of an object-system type.

§Safety

Self must have a compatible C layout with a valid TVMFFIObject prefix at offset zero, and embed a Self::Parent there unless it is the root. Its registered type, inheritance and payload must describe that layout correctly, including for foreign declarations.

A live managed object and its header must remain at their original allocation address until destruction. Safe APIs must not move, replace or expose mutable access to that header while managed; payload mutation must preserve its type invariants. Preallocation builders and values moved out during destruction are not live managed objects and cannot be borrowed as AnyView.

Required Associated Constants§

Source

const TYPE_KEY: &'static str

The type key, such as "ffi.Array".

Source

const TYPE_DEPTH: i32

Depth of this type in the object inheritance tree.

The root Object has depth zero, and every registered subtype has depth one greater than its parent. This value must be non-negative and agree with the runtime type table entry for Self.

Required Associated Types§

Source

type Parent

The parent’s object type, which Self embeds at offset zero; () for the root Object.

Required Methods§

Source

fn type_index() -> i32

The runtime type index of this type.

Source

unsafe fn object_header_mut(this: &mut Self) -> &mut TVMFFIObject

The object header, mutably.

§Arguments
  • this - The object.
§Safety

The caller must have exclusive access to the header and preserve the managed allocation’s address, reference counts, deleter and dynamic type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl ObjectCore for AccessPathObj

Source§

const TYPE_KEY: &'static str = "ffi.reflection.AccessPath"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for AccessStepObj

Source§

const TYPE_KEY: &'static str = "ffi.reflection.AccessStep"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for ArrayObj

Source§

const TYPE_KEY: &'static str = "ffi.Array"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for EnumObj

Source§

const TYPE_KEY: &'static str = "ffi.Enum"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for ErrorObj

Source§

const TYPE_KEY: &'static str = "ffi.Error"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for FunctionObj

Source§

const TYPE_KEY: &'static str = "ffi.Function"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for ListObj

Source§

const TYPE_KEY: &'static str = "ffi.List"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for MapObj

Source§

const TYPE_KEY: &'static str = "ffi.Map"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for ModuleObj

Source§

const TYPE_KEY: &'static str = "ffi.Module"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for Object

Source§

const TYPE_KEY: &'static str = "ffi.Object"

Source§

const TYPE_DEPTH: i32 = 0

Source§

type Parent = ()

Source§

impl ObjectCore for ShapeObj

Source§

const TYPE_KEY: &'static str = "ffi.Shape"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for TensorObj

Source§

const TYPE_KEY: &'static str = "ffi.Tensor"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object

Source§

impl ObjectCore for VisitInterruptObj

Source§

const TYPE_KEY: &'static str = "ffi.VisitInterrupt"

Source§

const TYPE_DEPTH: i32

Source§

type Parent = Object