Skip to main content

Module walker

Module walker 

Source
Expand description

Single-source data walker for descriptor ↔ RuntimeValue ↔ AlignedValue round trips.

The atom-flat descriptors (Boolean / Counter / Field / Uint / Bytes / Opaque / Vector / Tuple / Struct / Enum / Cell / Alias) are covered by crate::ir::descriptor — bidirectional, fully typed. This module re-exports those primitives under the walker name and adds the storage-shape helpers (Map / Set / List / MerkleTree / HistoricMerkleTree) that the descriptor module can’t cover because they aren’t atom-flat.

Convention is the one crate::ir::descriptor::decode_aligned_value uses across the codebase: Bytes<N> / Field / Opaque<Uint8Array> decode into RuntimeValue::String(hex), Counter / small Uint<…> into RuntimeValue::Int, big Uint<…> into RuntimeValue::String(decimal), structs into objects keyed by IR field name, enums into the variant-name string. Generated code on every binding language (Rust, TypeScript via napi/wasm, Swift/Python/etc via uniffi) projects from there into language- idiomatic typed shapes.

Re-exports§

pub use crate::ir::descriptor::decode_aligned_value;
pub use crate::ir::descriptor::decode_aligned_value_full;
pub use crate::ir::descriptor::encode_bool;
pub use crate::ir::descriptor::encode_bytes;
pub use crate::ir::descriptor::encode_default;
pub use crate::ir::descriptor::encode_field;
pub use crate::ir::descriptor::encode_literal;
pub use crate::ir::descriptor::encode_uint;
pub use crate::ir::descriptor::json_as_u128;

Functions§

aligned_value_from_atoms
Build an AlignedValue directly from a raw atom slice and an alignment singleton. Skips the round-trip when the caller already knows the descriptor and just needs to wrap raw atoms.
atom_buffer_to_aligned
Reconstruct an AlignedValue from an AtomBuffer (i.e. the shape crate::ledger produces). Useful for callers that need to pass a ledger snapshot back into encode_literal or any other surface that wants AlignedValue. Alignment metadata is rebuilt from descriptor so the result matches what the encoder would have produced for the same logical value.
walk_cell
Walk a Cell<T> snapshot — typed by the inner descriptor.
walk_counter
Walk a Counter snapshot. Always 8-byte unsigned.
walk_historic_merkle_tree
Walk a HistoricMerkleTree<depth, T> snapshot into a { live: MerkleTree, history: [MerkleTree] } object.
walk_list
Walk a List<T> snapshot.
walk_map
Walk a Map<K, V> snapshot. Keys are projected through the key descriptor and stringified for the resulting object’s keys; values project through the value descriptor (an empty atom buffer in the value slot becomes RuntimeValue::Null, matching the way Set<T> is on-chain encoded as Map<T, Null>).
walk_merkle_tree
Walk a MerkleTree<depth, T> snapshot into a { root: bytes, height: int } object — byte-honest.
walk_set
Walk a Set<T> snapshot.