pub enum Value {
Unit,
Bool(bool),
Int(i64),
Float(f64),
Pid(u64),
Message(Message),
Cap(u64),
Str(Arc<str>),
Bytes(Arc<[u8]>),
}Expand description
A dynamically-tagged runtime value.
Value::Cap is an unforgeable address for Send / Ask (phase 2).
Value::Pid remains for identity inside authenticated messages
(Message.sender / msg_sender), not for ambient addressing.
Value::Str / Value::Bytes are heap payloads shared via Arc so
register moves and mailbox hops clone the handle, not the buffer.
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(u64)
Unforgeable capability (CapId as u64). Required for Send / Ask.
Str(Arc<str>)
UTF-8 text (constant pool, natives, host).
Bytes(Arc<[u8]>)
Opaque byte buffer (constant pool, natives, host).
Implementations§
Source§impl Value
impl Value
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, and empty Value::Bytes.
pub fn as_int(&self) -> Option<i64>
pub fn as_pid(&self) -> Option<u64>
pub fn as_cap(&self) -> Option<u64>
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).
§This is a charge model, not an RSS measurement
Value::Str / Value::Bytes 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 budget that
under-counts shared payloads is not a bound at all, since a single
producer could fan one large Arc out to every inbox and stay
“within budget” everywhere while the host pays once per distinct
buffer it keeps alive.
The inline size_of::<Value>() term is included so a flood of
scalar hops is also bounded, not just blob hops.
Sourcepub fn heap_size(&self) -> usize
pub fn heap_size(&self) -> usize
Heap bytes owned (transitively) by this value, excluding the enum itself. Zero for every scalar variant.