Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Values

Every piece of data in the AVM flows through the Val type: messages between objects, internal state, function arguments, and results.

Variants

VariantRust typeExample
Nat(n)u64Val::Nat(42)
Bool(b)boolVal::Bool(true)
Str(s)StringVal::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))
NothingVal::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 object
  • Output = Val — responses from an object

Identifiers

The AVM uses newtype wrappers to prevent mixing different kinds of IDs:

  • ObjectId(String) — unique object identifier
  • MachineId(String) — physical machine
  • ControllerId(String) — logical transaction controller
  • TxId(u64) — transaction identifier

All are generated by FreshIdGen, a monotonic counter.