pub enum Value {
Unit,
Bool(bool),
Int(i64),
Float(f64),
Pid(u64),
Message(Message),
Cap(CapId),
Str(Arc<str>),
Bytes(Arc<[u8]>),
List(Arc<[Value]>),
Map(Arc<[(MapKey, Value)]>),
Record(Arc<[Value]>),
}Expand description
A dynamically-tagged runtime value.
Value::Cap is an opaque CapId for Send / Ask. Authority lives
in the runtime capability table, keyed by holder — not in this tag.
Value::Pid remains for identity inside authenticated messages.
Value::Str / Value::Bytes are heap payloads shared via Arc.
Variants§
Unit
Bool(bool)
Int(i64)
Float(f64)
Pid(u64)
Internal / message identity (FlowId as u64). Not a Send target.
Message(Message)
Atomic Hop envelope. See Message.
Cap(CapId)
Opaque capability token. Required for Send / Ask.
Str(Arc<str>)
UTF-8 text (constant pool, natives, host).
Bytes(Arc<[u8]>)
Opaque byte buffer (constant pool, natives, host).
List(Arc<[Value]>)
Bounded sequence (ABI v6 wire tag 9). At most MAX_LIST_LEN
elements; nesting shares the decoder depth ceiling with Message.
Map(Arc<[(MapKey, Value)]>)
Bounded map (ABI v7 wire tag 10). At most MAX_MAP_LEN pairs.
Insertion order is kept. A duplicate key is rejected at construction.
Record(Arc<[Value]>)
Positional record (ABI v8 wire tag 11). At most MAX_RECORD_LEN
fields. Not a map and not a receive pattern.
Implementations§
Source§impl Value
impl Value
Sourcepub fn wire_tag(&self) -> u8
pub fn wire_tag(&self) -> u8
BFV0 wire tag for this value (Unit=0 … Bytes=8, List=9, Map=10,
Record=11).
Used by crate::Opcode::ReceiveMatchKind selective receive, which
names tags 0..=10. A record is tag 11 and is not a receive pattern.
Sourcepub fn map_get(&self, key: &MapKey) -> Option<&Value>
pub fn map_get(&self, key: &MapKey) -> Option<&Value>
Value stored under key, if self is a map that contains it.
Sourcepub fn try_map(entries: Vec<(MapKey, Value)>) -> Option<Self>
pub fn try_map(entries: Vec<(MapKey, Value)>) -> Option<Self>
Build a Value::Map. Fails when there are more than MAX_MAP_LEN
pairs, a key is repeated, or nesting exceeds the decoder ceiling.
Sourcepub fn try_list(items: Vec<Value>) -> Option<Self>
pub fn try_list(items: Vec<Value>) -> Option<Self>
Build a Value::List. Fails when items is longer than
MAX_LIST_LEN or the nested Message / List depth exceeds the
decoder ceiling.
Sourcepub fn try_record(fields: Vec<Value>) -> Option<Self>
pub fn try_record(fields: Vec<Value>) -> Option<Self>
Build a Value::Record. Fails when fields is longer than
MAX_RECORD_LEN or nesting exceeds the decoder ceiling.
Sourcepub fn str(s: impl AsRef<str>) -> Self
pub fn str(s: impl AsRef<str>) -> Self
Build a Value::Str from anything string-like.
Sourcepub fn bytes(b: impl AsRef<[u8]>) -> Self
pub fn bytes(b: impl AsRef<[u8]>) -> Self
Build a Value::Bytes from a byte slice.
Sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Truthiness used by Opcode::Branch: falsy are Unit, Bool(false),
Int(0), empty Value::Str, empty Value::Bytes, empty
Value::List, empty Value::Map, and empty Value::Record.
Sourcepub fn as_int(&self) -> Option<i64>
pub fn as_int(&self) -> Option<i64>
Int, or Bool as 0 / 1.
This coercion is for host natives (crate::vm::expect_int). Opcode
operands that require an integer (Sleep, tags, request_id) do not
use it — a Bool there is a type error.
pub fn as_pid(&self) -> Option<u64>
pub fn as_cap(&self) -> Option<CapId>
pub fn as_message(&self) -> Option<&Message>
pub fn as_str(&self) -> Option<&str>
pub fn as_bytes(&self) -> Option<&[u8]>
Sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
Bytes this value is charged for against a mailbox byte budget
(see crate::MailboxBytes).
Value::Str / Value::Bytes / hop payloads are Arc-shared: the
same buffer cloned into N mailboxes exists once in memory, but each
mailbox is charged the full length. That over-counts on purpose.
A Message chain deeper than the decoder depth ceiling does not
walk the tail. The returned size is usize::MAX, which no mailbox
budget can admit.
Sourcepub fn heap_size(&self) -> usize
pub fn heap_size(&self) -> usize
Heap bytes owned (transitively) by this value, excluding the enum itself.
One Arc inside this value is counted once. A chain past the decoder
ceiling yields usize::MAX instead of recursing.