Skip to main content

HeapHeader

Struct HeapHeader 

Source
pub struct HeapHeader {
    pub kind: u16,
    pub elem_type: u8,
    pub flags: u8,
    pub len: u32,
    pub cap: u32,
    pub aux: u64,
    /* private fields */
}
Expand description

Fixed-layout header for heap-allocated objects.

This struct is designed to be readable by JIT-generated code at known offsets. The JIT can load kind at offset 0, len at offset 4, and aux at offset 16 without any Rust ABI knowledge.

Fields§

§kind: u16

Object type discriminator (matches HeapKind and HEAP_KIND_* constants).

§elem_type: u8

Element type hint for homogeneous containers (0 = untyped/mixed). For arrays: 1=f64, 2=i64, 3=string, 4=bool, 5=typed_object. For typed objects: unused (0).

§flags: u8

Bitfield flags (FLAG_MARKED, FLAG_PINNED, FLAG_READONLY).

§len: u32

Element count (array length, field count, string byte length, etc.).

§cap: u32

Allocated capacity (for growable containers). 0 if not applicable.

§aux: u64

Auxiliary data interpreted per-kind:

  • TypedObject: schema_id (u64)
  • Closure: function_id (low u16) | captures_count (next u16)
  • TypedTable/RowView/ColumnRef/IndexedTable: schema_id (u64)
  • Future: future_id (u64)
  • Enum: variant_id (low u32)
  • Other: 0

Implementations§

Source§

impl HeapHeader

Source

pub const OFFSET_KIND: usize = 0

Byte offset of the kind field from the start of the header.

Source

pub const OFFSET_ELEM_TYPE: usize = 2

Byte offset of the elem_type field.

Source

pub const OFFSET_FLAGS: usize = 3

Byte offset of the flags field.

Source

pub const OFFSET_LEN: usize = 4

Byte offset of the len field.

Source

pub const OFFSET_CAP: usize = 8

Byte offset of the cap field.

Source

pub const OFFSET_AUX: usize = 16

Byte offset of the aux field.

Source

pub fn new(kind: HeapKind) -> Self

Create a new HeapHeader with the given kind. All other fields are zeroed.

Source

pub fn with_len_aux(kind: HeapKind, len: u32, aux: u64) -> Self

Create a HeapHeader with kind, length, and auxiliary data.

Source

pub fn from_heap_value(value: &HeapValue) -> Self

Build a HeapHeader from an existing HeapValue.

Extracts kind, length, and auxiliary data from the HeapValue’s contents.

Source

pub fn heap_kind(&self) -> Option<HeapKind>

Get the HeapKind from this header.

Source

pub fn has_flag(&self, flag: u8) -> bool

Check if a flag is set.

Source

pub fn set_flag(&mut self, flag: u8)

Set a flag.

Source

pub fn clear_flag(&mut self, flag: u8)

Clear a flag.

Trait Implementations§

Source§

impl Clone for HeapHeader

Source§

fn clone(&self) -> HeapHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HeapHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for HeapHeader

Source§

fn eq(&self, other: &HeapHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for HeapHeader

Source§

impl Eq for HeapHeader

Source§

impl StructuralPartialEq for HeapHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,