logos.lang.writ.anyval
Module lang · package logos-lang
Types
enumWAny
enum WAny
Heterogeneous Writ value slot: one 8-byte word holding either an inline tagged
primitive (Pod) or a type-erased pointer to a tagged zone object (Ref).
null = Ref(0). Non-owning (Copy) — the Writ arena owns Ref pointees.
Implements: Copy Primitive WritField
Variants
Pod(u64)
Ref(*const u8)
Methods
fn as_bool(self: &WAny) -> bool
Returns true iff the inline Pod value (bits[63:8]) is nonzero.
fn as_f32(self: &WAny) -> f32
Returns the boxed f32 value; null or Pod → 0.0 (floats are never inline).
fn as_f64(self: &WAny) -> f64
Returns the boxed f64 value; null or Pod → 0.0.
fn as_i16(self: &WAny) -> i16
Returns the inline value narrowed to i16; truncates on mismatch (pair with is_i16).
fn as_i24(self: &WAny) -> i24
Returns the inline value narrowed to i24; truncates on mismatch (pair with is_i24).
fn as_i56(self: &WAny) -> i64
Returns the inline Pod value: bits[63:8] sign-extended to i64.
fn as_i64(self: &WAny) -> i64
Returns the integer value: inline Pod → sign-extended i56, boxed Ref → the 64-bit pointee, null → 0 (ADR 0011 absent-key default).
fn as_i8(self: &WAny) -> i8
Returns the inline value narrowed to i8; a wrong accessor truncates (pair with is_i8).
fn as_u16(self: &WAny) -> u16
Returns the inline value narrowed to u16; truncates on mismatch (pair with is_u16).
fn as_u24(self: &WAny) -> u24
Returns the inline value narrowed to u24; truncates on mismatch (pair with is_u24).
fn as_u64(self: &WAny) -> u64
Returns the unsigned value: inline Pod → as_i56() as u64, boxed Ref → the
64-bit pointee, null → 0.
fn as_u8(self: &WAny) -> u8
Returns the inline value narrowed to u8; truncates on mismatch (pair with is_u8).
fn from(v: u24) -> WAny
Creates a WT_U24-tagged inline Pod.
fn is_array(self: &WAny) -> bool
Returns true iff a Ref to a W_ARRAY arena object.
fn is_bool(self: &WAny) -> bool
Returns true iff an inline Pod tagged WA_BOOL.
fn is_f32(self: &WAny) -> bool
Returns true iff a Ref to a boxed W_F32 object.
fn is_float(self: &WAny) -> bool
Returns true iff a Ref to a boxed float (W_F32 or W_F64); floats never inline.
fn is_i16(self: &WAny) -> bool
Returns true iff an inline Pod tagged WT_I16.
fn is_i24(self: &WAny) -> bool
Returns true iff an inline Pod tagged WT_I24.
fn is_i56(self: &WAny) -> bool
Returns true iff an inline Pod tagged WA_I56.
fn is_i8(self: &WAny) -> bool
Returns true iff an inline Pod tagged WT_I8.
fn is_int(self: &WAny) -> bool
Returns true iff an integer in any form: inline Pod (WA_I56 or exact-width)
or boxed W_I64/W_U64.
fn is_map(self: &WAny) -> bool
Returns true iff a Ref to a W_MAP arena object.
fn is_null(self: &WAny) -> bool
Returns true iff the raw word is 0 (the null reference).
fn is_pod(self: &WAny) -> bool
Returns true iff this holds an inline Pod (low bit 1).
fn is_ref(self: &WAny) -> bool
Returns true iff this holds a non-null Ref (low bit 0, word != 0).
fn is_string(self: &WAny) -> bool
Returns true iff a Ref to a W_STRING arena object.
fn is_tinymap(self: &WAny) -> bool
Returns true iff a Ref to a W_TINYMAP (bitmap-indexed tiny map) object.
fn is_u16(self: &WAny) -> bool
Returns true iff an inline Pod tagged WT_U16.
fn is_u24(self: &WAny) -> bool
Returns true iff an inline Pod tagged WT_U24.
fn is_u64(self: &WAny) -> bool
Returns true iff a Ref to a boxed W_U64 object (inline Pods never carry u64).
fn is_u8(self: &WAny) -> bool
Returns true iff an inline Pod tagged WT_U8.
fn null() -> WAny
Creates the null WAny (Ref(0); raw word 0).
fn pod(v: i64, code: u8) -> WAny
Creates an inline Pod: code = 7-bit Writ type code (1..=127); v must fit
56 signed bits (see fits_i56) — wider values box into a Ref instead.
fn pod_bool(b: bool, code: u8) -> WAny
Creates an inline boolean Pod (value 1/0) tagged with code.
fn pod_code(self: &WAny) -> u8
Returns the Pod’s 7-bit type code (bits[7:1]); meaningful only when is_pod().
fn raw(self: &WAny) -> i64
Returns the raw 8-byte word: Pod → the tagged word, Ref → the absolute pointer bits.
fn ref_to(obj: *const u8) -> WAny
Creates a WAny referencing the tagged zone object obj (absolute value form).
fn resolve(self: &WAny) -> *const u8
Returns the Ref’s absolute tagged-object pointer; safe to obtain, unsafe to dereference.
fn type_code(self: &WAny) -> u64
Returns the unified type code: Pod → inline pod code, Ref → the pointee’s in-band tag, null → 0.
structWAnyMut
struct WAnyMut
Mutable dual of WAny: a fat handle pairing an at-rest element slot with its Writ
zone, able to read a Pod, descend/grow a Ref, and replace the element in place.
Produced by container get_mut; the parent’s zone cascades into the child.
Fields
slot: *zoned mut WAny
At-rest element slot (never-move arena); *slot materialises, *slot = v lowers.
zone: *mut u8
The Writ zone (allocator) the slot lives in, erased to *mut u8 (cast at use).
Methods
fn as_any(self: &WAnyMut) -> WAny
Returns the materialised element value at this cursor.
fn as_i56(self: &WAnyMut) -> i64
Returns the element’s inline Pod value, sign-extended from 56 bits.
fn get(self: &WAnyMut) -> WAny
Reads the element value (materialises the at-rest slot to an absolute WAny).
fn is_array(self: &WAnyMut) -> bool
Returns true iff the element is a W_ARRAY object.
fn is_map(self: &WAnyMut) -> bool
Returns true iff the element is a W_MAP object.
fn is_pod(self: &WAnyMut) -> bool
Returns true iff the element is an inline Pod.
fn is_ref(self: &WAnyMut) -> bool
Returns true iff the element is a non-null Ref.
fn is_string(self: &WAnyMut) -> bool
Returns true iff the element is a W_STRING object.
fn set(self: &WAnyMut, v: WAny) -> void
Replaces the element in place (lowers the new value into the slot).
fn type_code(self: &WAnyMut) -> u64
Returns the materialised element’s unified type code (see WAny::type_code).
Functions
fnfits_i56
fn fits_i56(v: i64) -> bool
Returns true iff v fits the 56-bit signed inline Pod range (else it must be boxed).
fnw_type_code
fn w_type_code(obj: *const u8) -> u64
Reads the in-band type tag written immediately before a tagged arena object (legacy
datatag varint): obj[-1] in 1..=222 is the code directly; a header 223..=230 means
header-222 little-endian code bytes follow at obj[-2], obj[-3], …; 0 or >230 = unset (0).