Skip to main content

Value

Struct Value 

Source
pub struct Value { /* private fields */ }
Expand description

Value-model re-exports: the word, its payload, type descriptors, and the export hook live in crate::value, the single representation for every type.

Implementations§

Source§

impl Value

Source

pub fn descriptor(&self) -> &'static TypeDescriptor

The word’s canonical descriptor singleton: the vtable backing its lifecycle and operations.

Source

pub fn type_name(&self) -> &'static str

The word’s registered type name (the descriptor’s name).

Source

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.

Source

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.

Source

pub fn mint_inline<T>(descriptor: &'static TypeDescriptor, value: T) -> Value
where T: Copy + PartialEq + Display + Debug + Send + Sync + 'static,

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.

Source

pub fn mint_heap<T>(descriptor: &'static TypeDescriptor, value: T) -> Value
where T: Clone + PartialEq + Display + Debug + Send + Sync + 'static,

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.

Source

pub fn mint_heap_shared<T>( descriptor: &'static TypeDescriptor, value: T, ) -> Value
where T: Clone + PartialEq + Display + Debug + Send + Sync + 'static,

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.

Source

pub fn read_inline<T>(&self, expected: &'static TypeDescriptor) -> Option<T>
where T: Copy + PartialEq + Display + Debug + Send + Sync + 'static,

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.

Source

pub fn read_heap<T>(&self, expected: &'static TypeDescriptor) -> Option<&T>
where T: Clone + PartialEq + Display + Debug + Send + Sync + 'static,

Borrow a heap word’s concrete value. Returns None when the word carries a different descriptor.

Source

pub fn read_heap_mut<T>( &mut self, expected: &'static TypeDescriptor, ) -> Option<&mut T>
where T: Clone + PartialEq + Display + Debug + Send + Sync + 'static,

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.

Source

pub fn int(n: i64) -> Value

Construct an integer word (inline, zero allocation).

Source

pub fn float(f: f64) -> Value

Construct a float word (inline, zero allocation).

Source

pub fn bool(b: bool) -> Value

Construct a boolean word (inline, zero allocation).

Source

pub fn handle(id: u64) -> Value

Construct a task-handle word (inline, zero allocation).

Source

pub fn string(s: String) -> Value

Construct a string word.

Source

pub fn list(items: Vec<Value>) -> Value

Construct a list word (shared heap: clones share the buffer).

Source

pub fn map(entries: BTreeMap<String, Value>) -> Value

Construct a map word (shared heap: clones share the buffer).

Source

pub fn path(p: PathBuf) -> Value

Construct a path word.

Source

pub fn duration(d: Duration) -> Value

Construct a duration word.

Source

pub fn pipe_fresh() -> Value

Construct a fresh unbound pipe handle (LET $p: PIPE, host new_pipe()). Materializes lazily on first binding.

Source

pub fn pipe_fresh_in_task(task_id: u64) -> Value

Construct a fresh unbound pipe handle declared by task_id (0 = root flow). The id travels with every clone so promotion checks always see the declaration origin.

Source

pub fn pipe_handle(handle: PipeHandle) -> Value

Wrap an existing handle as a PIPE word. Clones share the backend.

Source

pub fn semaphore(max: usize) -> Value

Construct a semaphore word admitting at most max concurrent holders. Every clone names the same backend.

Source

pub fn permit(sem: &Arc<SemaphoreState>) -> Value

Mint a PERMIT word bound to sem. The permit returns to the semaphore when the last clone of the word drops.

Source

pub fn as_semaphore(&self) -> Option<Arc<SemaphoreState>>

Borrow the semaphore backend out of a SEMAPHORE word. Returns None for non-SEMAPHORE words. The clone shares the backend.

Source

pub fn as_i64(&self) -> Option<i64>

Read an integer payload. Returns None for non-INT words.

Source

pub fn as_f64(&self) -> Option<f64>

Read a float payload. Returns None for non-FLOAT words.

Source

pub fn as_bool(&self) -> Option<bool>

Read a boolean payload. Returns None for non-BOOL words.

Source

pub fn as_handle(&self) -> Option<u64>

Read a task-handle payload. Returns None for non-HANDLE words.

Source

pub fn as_str(&self) -> Option<&str>

Borrow a string payload. Returns None for non-STRING words.

Source

pub fn as_list(&self) -> Option<&Vec<Value>>

Borrow a list payload. Returns None for non-LIST words.

Source

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.

Source

pub fn as_map(&self) -> Option<&BTreeMap<String, Value>>

Borrow a map payload. Returns None for non-MAP words.

Source

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.

Source

pub fn as_pipe_handle(&self) -> Option<PipeHandle>

Clone the pipe handle out of a PIPE word. Returns None for non-PIPE words. The clone shares the backend cell.

Source

pub fn as_duration(&self) -> Option<Duration>

Read a duration payload. Returns None for non-DURATION words.

Source

pub fn as_path(&self) -> Option<&Path>

Borrow a path payload. Returns None for non-PATH words.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Drop for Value

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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.

Source§

impl Sync for Value

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more