logos.lang.writ.container

Module lang · package logos-lang

Traits

traitResident

trait Resident

A residency root (a segment set), type-erased so a holder is opaque.

Dropping the last Rc<dyn Resident> runs the concrete container’s Drop, freeing its segments.

Implemented by: Writ

Types

structHeld

struct Held

An escaped reference paired with a residency holder that keeps its arena alive.

Fields

holder: Rc<dyn Resident>
ptr: *const T

structHeldAny

struct HeldAny

An escaping WAny (stored by value) paired with a Writ holder that keeps the arena alive.

Fields

holder: Rc<dyn Resident>
val: WAny

Methods

fn resolve(self: &HeldAny) -> *const u8

Returns the held value’s raw word as an absolute pointer (tagged object for a Ref).

structSlot

struct Slot

Opaque handle to a T placed in the container — a stable, never-moving location.

Not directly dereferenceable; read it via Writ::get/get_mut, which tie the borrow to the container so views cannot outlive it.

Fields

p: *mut T

structWrit

struct Writ

Owned, mutable root container for a never-move zoned document.

Owns the segment arena by value; placed objects never move, so pointers and self-relative references into them stay valid for the container’s lifetime.

Implements: Resident

Fields

allocator: Allocator

The never-move segment arena; interior-mutable so placement works through &Writ.

root: i64

The document root — the top-level WAny stored as its raw 8-byte word (0 = null/unset).

Methods

fn float(self: &Writ, v: f64) -> WAny

Boxes v into a W_F64-tagged object in this arena; returns a Ref WAny to it.

fn int(self: &Writ, v: i64) -> WAny

Makes an integer WAny in this arena: inline Pod when v fits i56, else boxed.

fn put(self: &mut Writ, v: T) -> Slot<T>

Places v into a never-move segment and returns an opaque Slot handle to it.

fn set_root(self: &Writ, v: WAny) -> void

Sets the document root to v (interior-mutable: &self; stores the raw word).

Functions

fnalloc_tagged

fn alloc_tagged(a: *mut Allocator, size: i64, code: u64) -> *mut u8

Allocates a tagged arena object: an 8-byte tag slot, then size 8-aligned object bytes.

Writes the varint type code ending at obj[-1] and returns the object pointer; w_type_code(obj) reads the code back.

fnbox_f32

fn box_f32(a: *mut Allocator, v: f32) -> WAny

Boxes v into a W_F32-tagged 8-byte arena slot (4 used); returns a Ref WAny to it.

f32 never fits the inline integer Pod, so it is always boxed.

fnbox_f64

fn box_f64(a: *mut Allocator, v: f64) -> WAny

Boxes v into its own W_F64-tagged 8-byte arena object; returns a Ref WAny to it.

fnbox_i64

fn box_i64(a: *mut Allocator, v: i64) -> WAny

Boxes v into its own W_I64-tagged 8-byte arena object; returns a Ref WAny to it.

fnbox_u64

fn box_u64(a: *mut Allocator, v: u64) -> WAny

Boxes v into its own W_U64-tagged 8-byte arena object; returns a Ref WAny to it.

u64 is ALWAYS boxed (no inline unsigned-56 tag — keeps is_u64/as_u64 exact).

fnhold

fn hold(h: &mut Rc<Writ>, r: &T) -> Held<T>

Pairs r with a clone of the container’s residency holder — the escape form of a reference.

fnhold_any

fn hold_any(h: &mut Rc<Writ>, v: WAny) -> HeldAny

Pairs v with a clone of the container’s residency holder — the escape form of a WAny.

fnmake_int

fn make_int(a: *mut Allocator, v: i64) -> WAny

Makes an integer WAny: inline Pod when v fits i56, else boxed via box_i64.

fnw_write_tag

fn w_write_tag(obj: *mut u8, code: u64) -> void

Writes the in-band varint type tag code into the bytes immediately before obj.

Codes 1..=222 take one byte at obj[-1]; larger codes take a header byte at obj[-1] plus little-endian code bytes below it. code == 0 writes nothing.

fnwrit_alloc

fn writ_alloc(h: *mut Writ) -> *mut T

Places one uninitialised T into a never-move segment and returns a pointer to it.

The caller initialises the storage. The pointer is stable for the container’s lifetime. Returns null on OOM.

fnwrit_alloc_bytes

fn writ_alloc_bytes(h: *mut Writ, n: i64) -> *mut u8

Places n raw uninitialised bytes (8-aligned) and returns a pointer to them.

For self-describing blobs — Varchar payloads, etc. Stable for the container’s lifetime. Null on OOM.

fnwrit_alloc_n

fn writ_alloc_n(h: *mut Writ, n: i64) -> *mut T

Places n contiguous uninitialised T (array backing) in one segment.

Returns a pointer to element 0, stable for the container’s lifetime. Null on OOM.

fnwrit_free

fn writ_free(h: *mut Writ) -> void

Frees the container and all its segments en masse; h must not be used afterwards.

fnwrit_new

fn writ_new(seg_size: i64) -> Writ

Creates a container whose segments default to seg_size data bytes.

Safe: the returned container is a sound owned root, RAII-freed on drop.

fnwrit_rc

fn writ_rc(seg_size: i64) -> Rc<Writ>

Creates a refcounted (held) container; when the last holder drops, all segments free.