pub struct Value { /* private fields */ }Implementations§
Source§impl Value
impl Value
Sourcepub fn descriptor(&self) -> &'static TypeDescriptor
pub fn descriptor(&self) -> &'static TypeDescriptor
The word’s canonical descriptor singleton: the vtable backing its lifecycle and operations.
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The word’s registered type name (the descriptor’s name).
Sourcepub fn inline_bits(&self) -> u64
pub fn inline_bits(&self) -> u64
Raw payload bits, copied out. Meaningful for inline words (the value’s bytes); for heap words these are the box pointer’s bits.
Sourcepub fn heap_ptr(&self) -> *mut ()
pub fn heap_ptr(&self) -> *mut ()
Heap box (exclusive) or buffer (shared) pointer, copied out. Only meaningful for heap words; never dereferenced here. Reading (not dereferencing) is safe.
Sourcepub fn mint_inline<T>(descriptor: &'static TypeDescriptor, value: T) -> Self
pub fn mint_inline<T>(descriptor: &'static TypeDescriptor, value: T) -> Self
Mint an inline word: memcpy the value’s bytes into the payload.
Zero allocation. The descriptor must be the payload type’s own
OxDockType::descriptor(); mismatching them misdirects the vtable
and is unsound.
Sourcepub fn mint_heap<T>(descriptor: &'static TypeDescriptor, value: T) -> Self
pub fn mint_heap<T>(descriptor: &'static TypeDescriptor, value: T) -> Self
Mint an exclusive heap word: move the value into an owned Box<T>
behind a thin pointer. One box allocation. The descriptor must be the
payload type’s own OxDockType::descriptor(); mismatching them
misdirects the vtable and is unsound.
Mint a shared heap word: move the value into a reference-counted
Arc<T> behind a thin pointer. One allocation; later clones bump the
strong count instead of copying. The descriptor must be the payload
type’s own OxDockType::descriptor() built for the shared path
(#[oxdock_type(shared)]); mismatching them misdirects the vtable
and is unsound.
Sourcepub fn read_inline<T>(&self, expected: &'static TypeDescriptor) -> Option<T>
pub fn read_inline<T>(&self, expected: &'static TypeDescriptor) -> Option<T>
Read an inline word back out. Returns None when the word carries
a different descriptor; the load itself is infallible for a word
minted for T.
Sourcepub fn read_heap<T>(&self, expected: &'static TypeDescriptor) -> Option<&T>
pub fn read_heap<T>(&self, expected: &'static TypeDescriptor) -> Option<&T>
Borrow a heap word’s concrete value. Returns None when the word
carries a different descriptor.
Sourcepub fn read_heap_mut<T>(
&mut self,
expected: &'static TypeDescriptor,
) -> Option<&mut T>
pub fn read_heap_mut<T>( &mut self, expected: &'static TypeDescriptor, ) -> Option<&mut T>
Borrow a heap word’s concrete value mutably, detaching shared buffers
first (copy-on-write). Returns None when the word carries a
different descriptor. This is the only sound way to obtain &mut
access to a heap payload: exclusive heaps hand out their box
directly, shared heaps clone-then-hand-out when the strong count
exceeds 1 and mutate in place otherwise. Panics when called with an
inline descriptor, which has no heap buffer.
Sourcepub fn list(items: Vec<Value>) -> Self
pub fn list(items: Vec<Value>) -> Self
Construct a list word (shared heap: clones share the buffer).
Sourcepub fn map(entries: BTreeMap<String, Value>) -> Self
pub fn map(entries: BTreeMap<String, Value>) -> Self
Construct a map word (shared heap: clones share the buffer).
Sourcepub fn as_handle(&self) -> Option<u64>
pub fn as_handle(&self) -> Option<u64>
Read a task-handle payload. Returns None for non-HANDLE words.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Borrow a string payload. Returns None for non-STRING words.
Sourcepub fn as_list(&self) -> Option<&Vec<Value>>
pub fn as_list(&self) -> Option<&Vec<Value>>
Borrow a list payload. Returns None for non-LIST words.
Sourcepub fn as_list_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_list_mut(&mut self) -> Option<&mut Vec<Value>>
Borrow a list payload mutably, detaching the shared buffer first when
clones exist. Returns None for non-LIST words. This is the choke
point every future in-place container mutation must go through.
Sourcepub fn as_map(&self) -> Option<&BTreeMap<String, Value>>
pub fn as_map(&self) -> Option<&BTreeMap<String, Value>>
Borrow a map payload. Returns None for non-MAP words.
Sourcepub fn as_map_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
pub fn as_map_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
Borrow a map payload mutably, detaching the shared buffer first when
clones exist. Returns None for non-MAP words. This is the choke
point every future in-place container mutation must go through.
Sourcepub fn as_pipe_name(&self) -> Option<&str>
pub fn as_pipe_name(&self) -> Option<&str>
Borrow a pipe-name payload. Returns None for non-PIPE words.
Sourcepub fn as_duration(&self) -> Option<Duration>
pub fn as_duration(&self) -> Option<Duration>
Read a duration payload. Returns None for non-DURATION words.
Trait Implementations§
impl Send for Value
A DSL value: a TypeDescriptor vtable pointer plus a ValuePayload.
Fixed size (128 bits on 64-bit targets). Lifecycle and operations call
the vtable directly, with no table lookup and no lock; see the module
docs for the ownership discipline.