Values
Every piece of data in the AVM flows through the Val type: messages between
objects, internal state, function arguments, and results.
Variants
| Variant | Rust type | Example |
|---|---|---|
Nat(n) | u64 | Val::Nat(42) |
Bool(b) | bool | Val::Bool(true) |
Str(s) | String | Val::str("hello") |
List(v) | Vec<Val> | Val::list(vec![Val::Nat(1)]) |
Pair(a, b) | Box<Val>, Box<Val> | Val::pair(Val::Nat(1), Val::Nat(2)) |
Nothing | — | Val::Nothing |
Just(v) | Box<Val> | Val::just(Val::Nat(7)) |
Nothing and Just model the Maybe type from the specification. A call
that fails returns Nothing; a successful call wraps its result in Just.
Type aliases
Input = Val— messages sent to an objectOutput = Val— responses from an object
Identifiers
The AVM uses newtype wrappers to prevent mixing different kinds of IDs:
ObjectId(String)— unique object identifierMachineId(String)— physical machineControllerId(String)— logical transaction controllerTxId(u64)— transaction identifier
All are generated by FreshIdGen, a monotonic counter.