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
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
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
Enum
Enum variant value: Some(42), None, Ok(v), Err(e)
Regex
Compiled regex pattern: (pattern, flags)
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§
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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