logos.lang.writ.wstring

Module lang · package logos-lang

Types

structWString

struct WString

UTF-8 string interned in the never-move arena as a self-describing custom DST. Layout is exactly the wire shape [vlen(payload_len)][UTF-8 payload] — the length is encoded in-band, no sized prefix. Borrow as &WString; read back with as_str.

Implements: SelfDescribing

Fields

bytes: [u8]

The whole tail: vlen length prefix followed by the UTF-8 payload.

Methods

fn as_str(self: &WString) -> &[u8]

Returns the inline UTF-8 payload — the tail past its vlen prefix. The str borrows arena storage and stays valid while the container lives.

fn len(self: &WString) -> i64

Returns the logical string length in bytes — the vlen-decoded payload count. NOT dst_len, which is the whole tail including the vlen prefix (self.bytes materializes the tail; its data pointer is the vlen prefix).

Functions

fnwstring_in_alloc

fn wstring_in_alloc(alloc: *mut Allocator, s: &[u8]) -> *mut WString

Interns s through a raw Allocator: allocates vlen_encode_size(n) + n bytes in one arena chunk, writes the vlen length prefix, then copies the payload after it. Taking *mut Allocator (not the whole Writ) lets a container that holds only its allocator back-pointer — e.g. WArray<WAny> — intern strings without the full handle.