Skip to main content

GcTypeLayouts

Trait GcTypeLayouts 

Source
pub trait GcTypeLayouts {
    // Required methods
    fn array_length_field_offset(&self) -> u32;
    fn exception_tag_instance_offset(&self) -> u32;
    fn exception_tag_defined_offset(&self) -> u32;
    fn array_layout(&self, ty: &WasmArrayType) -> GcArrayLayout;
    fn struct_layout(
        &self,
        ty: &WasmStructType,
    ) -> Result<GcStructLayout, OutOfMemory>;
    fn exn_layout(
        &self,
        ty: &WasmExnType,
    ) -> Result<GcStructLayout, OutOfMemory>;

    // Provided method
    fn gc_layout(
        &self,
        ty: &WasmCompositeType,
    ) -> Result<Option<GcLayout>, OutOfMemory> { ... }
}
Expand description

A trait for getting the layout of a Wasm GC struct or array inside a particular collector.

Required Methods§

Source

fn array_length_field_offset(&self) -> u32

The offset of an array’s length field.

This must be the same for all arrays in the heap, regardless of their element type.

Source

fn exception_tag_instance_offset(&self) -> u32

The offset of an exception object’s tag reference: defining instance index field.

This must be the same for all exception objects in the heap, regardless of their specific signature.

Source

fn exception_tag_defined_offset(&self) -> u32

The offset of an exception object’s tag reference: defined tag index field.

This must be the same for all exception objects in the heap, regardless of their specific signature.

Source

fn array_layout(&self, ty: &WasmArrayType) -> GcArrayLayout

Get this collector’s layout for the given array type.

Source

fn struct_layout( &self, ty: &WasmStructType, ) -> Result<GcStructLayout, OutOfMemory>

Get this collector’s layout for the given struct type.

Source

fn exn_layout(&self, ty: &WasmExnType) -> Result<GcStructLayout, OutOfMemory>

Get this collector’s layout for the given exception type.

Provided Methods§

Source

fn gc_layout( &self, ty: &WasmCompositeType, ) -> Result<Option<GcLayout>, OutOfMemory>

Get this collector’s layout for the given composite type.

Returns None if the type is a function type, as functions are not managed by the GC.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§