Skip to main content

Module session_kv

Module session_kv 

Source
Expand description

Session-scoped key-value store: the trait an embedder implements and a bounded in-memory implementation.

Keys and payloads are UTF-16 code units end to end. A payload can contain lone surrogates — a value a Submilli string may legally hold — so nothing here round-trips through a Rust String, which would replace them.

The store outlives the Wasm store it is read from, so it never retains guest GC references: serialization to code units happens above this layer.

Structs§

CursorKey
A secret that seals session.list cursors, named by an id each cursor carries so a server holding several keys knows which one sealed it.
CursorKeys
The keys session.list cursors are sealed and opened with. New cursors are sealed with current; a cursor sealed with a retired key still opens, so replacing the key does not break listings already under way.
InMemorySessionKv
Bounded in-memory store, for embedders without durable storage and for state that must not outlive its owner.
SessionKvEntry
Key plus retained payload size — what list may disclose. Never contents.
SessionKvLimits
SessionKvPage
One page of a key scan.
SessionKvUsage
What a session holds when a write is checked against its limits.

Enums§

SessionKvError
SessionKvLimitKind
Which bound a rejected operation ran into. Carries the numbers, never the value — an error message about a quota must not leak session contents.

Constants§

CURSOR_KEY_ID_LEN
Bytes in a CursorKey id.
DEFAULT_MAX_ENTRIES
DEFAULT_MAX_KEY_UNITS
UTF-16 code units in a nonempty key.
DEFAULT_MAX_SESSION_BYTES
Retained serialized payload per session.
DEFAULT_MAX_VALUE_BYTES
Serialized payload of a single value.

Traits§

SessionKvStore
Session-scoped key-value storage.

Functions§

entry_bytes
Retained bytes for one entry: what the per-session limit counts.
render_key
Only ever used to name the key in a diagnostic. Lone surrogates become replacement characters here, which is acceptable in a message and is why the stored key itself is kept as code units.
value_bytes
Serialized bytes of a value: what the value limit and list count.

Type Aliases§

SessionKvFuture
What a SessionKvStore operation returns: a store may reach storage that must not block the caller’s thread.