Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 32 variants Int(i64), Float(f64), Bool(bool), String(Rc<String>), Bytes(Rc<RefCell<Vec<u8>>>), ByteSlice(Rc<Vec<u8>>), StrView(Rc<Vec<u8>>), U8(u8), Tensor(Tensor), SparseTensor(SparseCsr), Map(Rc<RefCell<DetMap>>), Array(Rc<Vec<Value>>), Struct { name: String, fields: BTreeMap<String, Value>, }, Tuple(Rc<Vec<Value>>), ClassRef(GcRef), Fn(FnValue), Closure { fn_name: String, env: Vec<Value>, arity: usize, }, Enum { enum_name: String, variant: String, fields: Vec<Value>, }, Regex { pattern: String, flags: String, }, Bf16(Bf16), F16(F16), Complex(ComplexF64), Scratchpad(Rc<RefCell<Scratchpad>>), PagedKvCache(Rc<RefCell<PagedKvCache>>), AlignedBytes(AlignedByteSlice), GradGraph(Rc<RefCell<dyn Any>>), OptimizerState(Rc<RefCell<dyn Any>>), TidyView(Rc<dyn Any>), GroupedTidyView(Rc<dyn Any>), VizorPlot(Rc<dyn Any>), QuantumState(Rc<RefCell<dyn Any>>), Void,
}
Expand description

The universal value type for the CJC interpreter.

Variants§

§

Int(i64)

§

Float(f64)

§

Bool(bool)

§

String(Rc<String>)

§

Bytes(Rc<RefCell<Vec<u8>>>)

Owning byte buffer.

§

ByteSlice(Rc<Vec<u8>>)

Non-owning byte slice view. In the interpreter this is an owning snapshot (Vec) since we can’t borrow across eval boundaries. The compiler/MIR path can use true zero-copy slices.

§

StrView(Rc<Vec<u8>>)

Validated UTF-8 string view (same representation as ByteSlice but guaranteed valid UTF-8).

§

U8(u8)

Single byte value (u8).

§

Tensor(Tensor)

§

SparseTensor(SparseCsr)

§

Map(Rc<RefCell<DetMap>>)

§

Array(Rc<Vec<Value>>)

Copy-on-write array. Rc provides O(1) clone; Rc::make_mut() triggers a deep copy only when the array is mutated and shared.

§

Struct

Fields

§name: String
§

Tuple(Rc<Vec<Value>>)

Copy-on-write tuple. Same COW semantics as Array.

§

ClassRef(GcRef)

§

Fn(FnValue)

§

Closure

A closure: a function name + captured environment values.

Fields

§fn_name: String
§env: Vec<Value>
§arity: usize

Arity of the original lambda params (not including captures).

§

Enum

Enum variant value: Some(42), None, Ok(v), Err(e)

Fields

§enum_name: String
§variant: String
§fields: Vec<Value>
§

Regex

Compiled regex pattern: (pattern, flags)

Fields

§pattern: String
§flags: String
§

Bf16(Bf16)

bf16 brain-float: u16-backed, deterministic f32 conversions

§

F16(F16)

f16 half-precision: u16-backed IEEE 754 binary16

§

Complex(ComplexF64)

Complex f64: deterministic fixed-sequence arithmetic

§

Scratchpad(Rc<RefCell<Scratchpad>>)

Pre-allocated KV-cache scratchpad for zero-allocation inference.

Runtime-only: No corresponding Type::Scratchpad exists. Created via Scratchpad.new() builtin. Type-checking treats it as opaque.

§

PagedKvCache(Rc<RefCell<PagedKvCache>>)

Block-paged KV-cache (vLLM-style).

Runtime-only: No corresponding Type::PagedKvCache exists. Created via PagedKvCache.new() builtin. Type-checking treats it as opaque.

§

AlignedBytes(AlignedByteSlice)

Aligned byte slice with 16-byte alignment guarantee.

Runtime-only: No corresponding Type::AlignedBytes exists. Created via AlignedByteSlice.from_bytes() builtin. Type-checking treats it as opaque.

§

GradGraph(Rc<RefCell<dyn Any>>)

Type-erased reverse-mode AD graph. Concrete type: cjc_ad::GradGraph. Uses Rc<RefCell<dyn Any>> because cjc-runtime cannot depend on cjc-ad. Construction and method dispatch happen in cjc-eval and cjc-mir-exec.

§

OptimizerState(Rc<RefCell<dyn Any>>)

Type-erased optimizer state. Concrete types: AdamState or SgdState (from ml.rs). Uses Rc<RefCell<dyn Any>> for interior mutability (step updates internal state).

§

TidyView(Rc<dyn Any>)

Type-erased tidy data view. Concrete type is cjc_data::TidyView. Wrapped in Rc<dyn Any> for cheap cloning without circular deps (cjc-runtime cannot depend on cjc-data).

Dispatch is handled by cjc_data::tidy_dispatch::dispatch_tidy_method.

§

GroupedTidyView(Rc<dyn Any>)

Type-erased grouped tidy view. Concrete type is cjc_data::GroupedTidyView. Same erasure strategy as TidyView.

§

VizorPlot(Rc<dyn Any>)

Type-erased Vizor plot specification. Concrete type is cjc_vizor::spec::PlotSpec. Same erasure strategy as TidyView.

Dispatch is handled by cjc_vizor::dispatch::dispatch_vizor_method.

§

QuantumState(Rc<RefCell<dyn Any>>)

Type-erased quantum state (circuit or statevector). Concrete type: cjc_quantum::Circuit or cjc_quantum::Statevector. Uses Rc<RefCell<dyn Any>> for interior mutability (measurement collapses state). Construction and method dispatch happen in cjc-eval and cjc-mir-exec.

§

Void

Implementations§

Source§

impl Value

Source

pub fn type_name(&self) -> &str

Returns a human-readable type name for error messages.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · 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

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

impl Display for Value

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl !UnwindSafe for Value

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.