logos.mem.writ.tag_system

Module mem · package logos-mem

Traits

traitTagSystem

trait TagSystem

Encapsulates how a type tag (type_code) is read from a raw memory object. Each impl receives a pointer to the first byte of the object and locates the tag according to its format.

Implemented by: WritTypeTagSystem DataTypeTagSystem WritTagSystem TomTagSystem

Types

structDataTypeTagSystem

struct DataTypeTagSystem

Reads the vlen datatag of user Writ zone datatypes (#[type_code=N]). Same 1-8 byte pre-object format and decoder as WritTypeTagSystem.

Implements: TagSystem

Methods

fn read_tag(self: &DataTypeTagSystem, obj: *const u8) -> u64

structTomTagSystem

struct TomTagSystem

Reads the TOM (TinyObjectMap) tag: the little-endian u64 at byte offset 0 of the object header. Code 0 is the unset/invalid sentinel; callers reject it as needed.

Implements: TagSystem

Methods

fn read_tag(self: &TomTagSystem, obj: *const u8) -> u64

Reads the tag byte-by-byte (no alignment requirement on obj); returns 0 if the pointer arithmetic would overflow.

structWritTagSystem

struct WritTagSystem

Reads the vlen tag of Writ arena objects reached via self-relative RelAny/RelPtr. Same format as WritTypeTagSystem, but a deliberately separate dispatch namespace: one type_code may carry a base-relative impl there and a self-relative impl here.

Implements: TagSystem

Methods

fn read_tag(self: &WritTagSystem, obj: *const u8) -> u64

structWritTypeTagSystem

struct WritTypeTagSystem

Reads the vlen TypeTag of Writ core zone datatypes: variable-length bytes immediately before the object. obj[-1] in 1..=222 is the type_code itself; 223+ heads a multi-byte little-endian code. Tag value = type_code (u64).

Implements: TagSystem

Methods

fn read_tag(self: &WritTypeTagSystem, obj: *const u8) -> u64

Functions

fnw_tag_size

fn w_tag_size(code: u64) -> i64

Returns the byte length of the vlen datatag for code: 0 for the unset code 0, 1 for codes 1..=222, else 1 header byte + N little-endian code bytes.

fnwrite_tag

fn write_tag(obj: *mut u8, type_code: u64) -> void

Writes the vlen datatag for type_code immediately before obj (alias of w_write_tag; tests and user datatypes write tags by this historical name). Safety: the tag bytes below obj must be reserved and writable.