Collections for Nyxus and Hylix

The nyxus namespace supplies native collections for the Nyxus persistent heap engine. These facades explicitly carry cdk_rsx_engine_nyxus::Nyxus:

use cdk_rsx_collections::nyxus::{Map, Rc, NyxusData, String, Vec};
#[derive(NyxusData)]
struct Data { rows: Map<String, Rc<Vec<u64>>> }
let mut data = Data { rows: Map::new() };
data.rows.insert("items".into(), Rc::new(Vec::from([1, 2, 3])));

Derives require a direct cdk-rsx-engine-nyxus Cargo dependency. Vec/Map/Set/Queue use std Vec/BTreeMap/BTreeSet/VecDeque with Nyxus; Rc/Weak/Box use corresponding concrete retained std types. String preserves UTF-8 over a retained Vec. Growth, clone, split and destruction keep the explicit allocator. Serde serializes values and decodes retained containers; transport output remains transient and serde does not preserve Rc sharing.

SharedSlice<T> and SharedString share immutable bytes/elements in one source-owned header-and-tail allocation. They expose no mutable alias, weak owner or raw constructor. The actual header/element physical graph plus checked allocation/initialization/count/drop recipe must be certified together. Each carrier's proof supplies its own production-source interpretation recipe. The compiled root catalog follows those dependencies together with Nyxus's ALLOCATOR_POLICY, module semantics and concrete physical roots. There is no package-wide Collections policy to add. Native containers sharing an implementation file deliberately share that recipe; Hylix code does not enter a Nyxus-only carrier's policy. Custom comparator and drop implementations remain explicit owner dependencies.

Nyxus collections depend on the Nyxus engine, not Store. They have no value slots, resource-edge graph, codec, per-entry identity or collection sweep. Store accounts only opaque module ownership. NyxusData trait and derive are reexported for authoring; allocator lifecycle stays in Nyxus.

The hylix namespace supplies Hylix's offset-backed B-tree Map/Set, ring Queue, contiguous Vec, immutable Blob/String, unique Cell, mutable SharedCell and immutable Shared. These use the one cdk-rsx-engine-hylix arena supplied by a Store frame. Nyxus containers above retain their ordinary direct operations.

Hylix carriers implement fixed Codec plus explicit HylixValue ownership. Named records import OwnedRecord from cdk_rsx_collections::hylix; its implementation belongs to Collections' derive crate. The Hylix engine supplies the Codec and HylixValue derives. Their normal Rust destructors are inert. Insertion consumes an owned carrier; removal returns its ownership. Retire removed values which are not moved, and use hylix::replace when replacing an owning field. Shared snapshot() returns a clonable read view which cannot be persisted; share() explicitly creates another durable owning reference. Owning Shared deliberately has no Clone.

get returns a transient decoded Read<T> guard; get_mut returns Edit<T> which writes its fixed row on Drop, independently of Store's deferred module record publication at frame end. Neither exposes a reference into stable memory or a consuming snapshot conversion. Cell additionally checks aliased shared/exclusive loans by allocation identity. Cell keeps four simultaneously live identities inline, adds dynamic overflow as needed, and releases empty overflow before KEEP. Map nodes are bounded initialized records. Insertion searches each node once, retaining the leaf and only the ancestor suffix needed to absorb splits. All provider loans end before writes. A full node gains one transient workspace entry, then splits upward; no over-capacity node is persisted. Replacement copies no node. Insertion, deletion, borrowing and merging move live key/value/child planes without decoding or re-encoding unchanged owners. New key/value spans encode; removal decodes its returned row once. Internal predecessor/successor replacements transfer exact encodings, and root collapse reuses the current workspace. Growing a node moves later planes first; shrinking moves earlier planes first. New codec spans are zero-initialized, including padding. Retirement decodes the owners it consumes; bulk construction encodes converted rows. Point access decodes only probed keys and the selected value. Map::contains_by(compare) checks primary identity without decoding the value, using the same node/key/child validation primitives. It is the comparison-based presence counterpart to get_by; contains_key retains its ordinary point-read and value-codec validation path. Queue growth and Vec shifts use the arena's checked, overlap-safe Storage::copy_bytes operation with bounded reusable scratch. Iterator frames retain owned encoded bytes per level because they outlive the provider visit; borrowed read slices never escape. Stable ownership, schema interpretation and comparator contracts remain compiled release inputs; these collections do not recreate the removed Store object engine.

SharedCell keeps its owning-edge count and mutable payload in one stable allocation. Explicit share() adds an owner; snapshot() lends a nonpersistable view. Payload guards use the same alias-aware loans as Cell. Nonfinal retirement releases one count, while final retirement requires an exclusive payload loan before retiring children and freeing the allocation.

Package guides

Collection guide.