pub enum Value {
Show 20 variants
U64(u64),
U128(Bits128),
I128(Bits128),
Reg128(Bits128, RegLanes),
I64(i64),
F64(f64),
Bool(bool),
Str(Arc<str>),
Bytes(Arc<[u8]>),
Json(Arc<Value>),
Ext(Box<dyn ReflectedValue>),
Handle(Arc<dyn Any + Send + Sync>),
VecF32(SliceArc<f32>),
VecI32(SliceArc<i32>),
VecF64(SliceArc<f64>),
VecI64(SliceArc<i64>),
VecF16(SliceArc<f16>),
VecI16(SliceArc<i16>),
VecI8(SliceArc<i8>),
None,
}Expand description
A typed value on a wire: what a node reads and produces on the interpreter, and what a host sets and pulls on every engine.
Variants§
U64(u64)
Unsigned 64-bit integer. The workhorse type for deterministic data generation: hash outputs, modular arithmetic, bit manipulation, cycle counters, primary keys.
U128(Bits128)
Unsigned 128-bit integer (cranelift I128, unsigned
interpretation). Carried as two u64 limbs (Bits128,
little-endian limb order) so Value keeps alignment 8 —
see the value_size_probe test. Interpreter-only until
the two-slot JIT ABI lands (type_system_alignment.md
§8.1). JSON projection is a decimal string (JSON Number
cannot carry 128-bit magnitude).
I128(Bits128)
Signed 128-bit integer (cranelift I128, signed
interpretation). Same limb carrier and conventions as
Value::U128.
Reg128(Bits128, RegLanes)
128-bit SIMD register word (type_system_alignment.md
§8.4 layer 2). The RegLanes tag records the current
view — a homogeneous lane typing ([f32; 4], [i16; 8],
…) or Raw (algorithm-defined buffer state with
heterogeneous lane roles). Views are free bitcasts; the
word is a plain value (two u64 slots in compiled buffers,
no pointers, no lifetime).
I64(i64)
Signed 64-bit integer. The honest runtime carrier for
PortType::I64 (and sign-extended I32) slots — matching
serde_json::Number’s NegInt leaf so display and JSON
projection render negatives as negatives instead of their
unsigned bit-reinterpretation. At the JIT boundary the bits
ride the same u64 slot (i64 as u64 is a free bitcast), so
signedness costs nothing in compiled kernels. See
polydat/docs/design/type_system_alignment.md §5.
F64(f64)
IEEE 754 double-precision float. Used for distributions, noise functions, trigonometry, interpolation, and any computation that needs fractional precision.
Bool(bool)
Boolean. Used for conditional ops (if: field), selection
nodes, and flag computation.
Str(Arc<str>)
Shared, immutable UTF-8 string. Used for formatted output,
weighted string selection, template interpolation, and any
value that will appear directly in an op statement. Backed
by Arc<str> so cloning is one atomic increment with no
allocation — the per-cycle reads that materialize a final
or init string into op-template substitution are
pointer-share, not heap-copy.
Bytes(Arc<[u8]>)
Shared, immutable raw byte buffer. Used for cryptographic
digests, binary encoding/decoding, and byte-level data
generation. Backed by Arc<[u8]> so cloning is one atomic
increment.
Json(Arc<Value>)
Shared, immutable structured JSON value. Used for
vector representations (JSON arrays), complex structured
data, and JSON merge ops. Backed by Arc<serde_json::Value>
so cloning is one atomic increment — the per-cycle reads
of result-body JSON wires (capture extraction, recall
evaluation, column projection) share the underlying
allocation rather than deep-cloning the tree. Consumers
that need an owned serde_json::Value (mutation,
serialization sinks) explicitly deep-clone via
(*v).clone() at the consume site.
Ext(Box<dyn ReflectedValue>)
Adapter-contributed reflected value. Carries type info and standard access methods (display, JSON, string, bytes). Enables protocol-native types (UUIDs, timestamps, inet addresses) to flow through Polydat without boxing to strings.
Handle(Arc<dyn Any + Send + Sync>)
Type-erased Arc handle to a resolved resource (dataset,
prepared statement, …). Cloning during input gather is one
Arc::clone — a single atomic increment, zero allocations.
Produced by resolver nodes (e.g. dataset_open) and consumed
by reader nodes that downcast to the concrete type. See
SRD 53 §“Dataset Handles” for the canonical use case.
VecF32(SliceArc<f32>)
Typed f32 vector carrier. Flows from vector accessors to
native-binding adapters without string formatting or byte
serialization on the cycle path. Cloning is one Arc::clone,
zero allocations. The underlying SliceArc supports both
owned (allocated Arc<[f32]>) and zero-copy (borrow into a
long-lived owner like an mmap’d dataset) storage modes.
to_display_string() renders as JSON array.
VecI32(SliceArc<i32>)
Typed i32 vector carrier (e.g. neighbor indices). Same
shape as VecF32 — typed slice on the wire.
VecF64(SliceArc<f64>)
Typed f64 vector carrier (Arc<[f64]>). Same shape as
VecF32. Used for double-precision embeddings / dense
numeric features bound to CQL vector<double, N> etc.
VecI64(SliceArc<i64>)
Typed i64 vector carrier (Arc<[i64]>). 64-bit integer
vectors for CQL vector<bigint, N>.
VecF16(SliceArc<f16>)
Typed half-precision float vector (Arc<[half::f16]>).
16-bit float carrier — stays at f16 on the wire so
embeddings stored as half-precision aren’t widened on the
kernel side.
VecI16(SliceArc<i16>)
Typed i16 vector carrier (Arc<[i16]>). 16-bit signed
integer vectors for CQL vector<smallint, N>.
VecI8(SliceArc<i8>)
Typed i8 vector carrier (Arc<[i8]>). 8-bit signed
integer vectors (CQL vector<tinyint, N>); completes the
cranelift lane family {i8, i16, i32, i64, f16, f32, f64}
(type_system_alignment.md §8.2). Unsigned byte buffers are
spelled Bytes.
None
Sentinel for uninitialized buffer slots. Never appears in wiring — only in freshly allocated state buffers before first evaluation.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_i64(&self) -> i64
pub fn as_i64(&self) -> i64
Read a signed 64-bit integer. Accepts the honest Value::I64
carrier and — during the bit-stuffed-to-honest migration —
a legacy Value::U64 whose bits are reinterpreted (the
pre-alignment storage convention for PortType::I64 slots).
Sourcepub fn as_u128(&self) -> u128
pub fn as_u128(&self) -> u128
Read an unsigned 128-bit integer. Accepts the honest
Value::U128 carrier plus zero-extended U64 (widening
is implicit at read sites the way as_i64 accepts the
legacy stuffed form).
Sourcepub fn as_i128(&self) -> i128
pub fn as_i128(&self) -> i128
Read a signed 128-bit integer. Accepts Value::I128 plus
sign-extended I64 and zero-extended U64.
Sourcepub fn as_reg_bits(&self) -> Bits128
pub fn as_reg_bits(&self) -> Bits128
Read a 128-bit register word under any view (views are free bitcasts — a consumer declaring a different lane typing than the producer is the intended use).
Sourcepub fn as_bool(&self) -> bool
pub fn as_bool(&self) -> bool
The Bool payload; panics on any other variant, naming both types.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
The Bytes payload as a byte slice; panics on any other variant.
Sourcepub fn as_json_arc(&self) -> &Arc<Value> ⓘ
pub fn as_json_arc(&self) -> &Arc<Value> ⓘ
Borrow the inner Arc<serde_json::Value> from a
Value::Json variant. Use when a consumer wants to
share the JSON tree across kernels without deep-cloning
the structure — e.g. capture extraction that writes the
same JSON wire to multiple downstream slots. Panics on
type mismatch.
Sourcepub fn as_vec_f32(&self) -> &[f32]
pub fn as_vec_f32(&self) -> &[f32]
Borrow a VecF32 value as &[f32]. Panics on type mismatch.
Sourcepub fn satisfies_slot(&self, slot_type: PortType) -> bool
pub fn satisfies_slot(&self, slot_type: PortType) -> bool
Test whether this value’s runtime variant is acceptable
to a slot declaring slot_type. port_type() == slot_type
is the strict case; this method also accepts the
bit-stuffing equivalences documented in
polydat/docs/design/type_system.md §1:
Value::U64is the runtime storage forPortTypeU64,U32,I64, andI32(narrow integers carry their bits in the low part of the u64; sign-extension forI32is part of the producer convention).Value::F64is the runtime storage forPortTypeF64andF32(F32carries its bits in the low 32 viaf32::to_bits() as u64-style stuffing — but float stuffing usesValue::F64for the materialised float value, not the bit pattern).Value::Noneis acceptable for every slot type (SRD-74 absent sentinel).
Used at the typed-write residual check
(Dataflow::set_wire_idx) AFTER the boundary adapter has
already converted/validated the value — see
polydat/src/kernel/api_impl.rs. The pre-adapter check in
adapt_boundary_value stays strict (port_type == slot_type) so an unadapted Value::U64 can never silently
truncate into a narrower slot.
Sourcepub fn as_vec_i32(&self) -> &[i32]
pub fn as_vec_i32(&self) -> &[i32]
Borrow a VecI32 value as &[i32]. Panics on type mismatch.
Sourcepub fn as_vec_f64(&self) -> &[f64]
pub fn as_vec_f64(&self) -> &[f64]
Borrow a VecF64 value as &[f64]. Panics on type mismatch.
Sourcepub fn as_vec_i64(&self) -> &[i64]
pub fn as_vec_i64(&self) -> &[i64]
Borrow a VecI64 value as &[i64]. Panics on type mismatch.
Sourcepub fn as_vec_f16(&self) -> &[f16]
pub fn as_vec_f16(&self) -> &[f16]
Borrow a VecF16 value as &[half::f16]. Panics on type mismatch.
Sourcepub fn as_vec_i16(&self) -> &[i16]
pub fn as_vec_i16(&self) -> &[i16]
Borrow a VecI16 value as &[i16]. Panics on type mismatch.
Sourcepub fn as_handle<T: Any + Send + Sync>(&self) -> &T
pub fn as_handle<T: Any + Send + Sync>(&self) -> &T
Downcast a Handle value to a borrowed reference of its concrete
type. Panics if the variant isn’t Handle or the type doesn’t
match. Used by reader nodes that consume a typed-handle wire
produced by a resolver node (see SRD 53 §“Dataset Handles”).
The borrow lasts as long as self (the buffer slot’s Value
is what holds the Arc). For per-cycle reads this is the
expected pattern — call methods on the borrowed dataset, then
return.
Sourcepub fn handle<T: Any + Send + Sync>(arc: Arc<T>) -> Self
pub fn handle<T: Any + Send + Sync>(arc: Arc<T>) -> Self
Construct a Value::Handle from a typed Arc<T>. Convenience
wrapper that performs the type-erasure to Arc<dyn Any + Send + Sync>.
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Best-effort string representation for any value. Works across all variants including Ext.
Sourcepub fn to_display_strict(&self) -> Option<String>
pub fn to_display_strict(&self) -> Option<String>
Strict-render variant of Self::to_display_string for use
at wire-protocol render sites (op-template substitution,
adapter byte-emission paths).
Returns None for Value::None instead of converting it
to "". The empty-string mapping in to_display_string is
convenient for diagnostic / log contexts but lethal at the
wire boundary — it silently coerces “absent” into “present
but empty,” corrupting downstream bytes (e.g. sending
'source_model': '' to a CQL cluster when the intended
shadow didn’t bind). Render paths use this primitive and
surface a clear error when an unresolved bind-point reaches
them. See none_semantics.md
(the render-refuses-silent-None rule).
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
JSON representation for any value. Works across all variants.
Source§impl Value
impl Value
Sourcepub fn from_streamer(s: StreamerValue) -> Self
pub fn from_streamer(s: StreamerValue) -> Self
Wrap a StreamerValue as a Value::Ext.
Sourcepub fn as_streamer(&self) -> Option<&StreamerValue>
pub fn as_streamer(&self) -> Option<&StreamerValue>
Downcast to a StreamerValue. None if the value is not a
streamer.
Source§impl Value
Convenience constructors and downcasters on Value for
partition-typed wires. Use these at node entry / exit to
avoid Value::Ext(Box::new(...)) boilerplate.
impl Value
Convenience constructors and downcasters on Value for
partition-typed wires. Use these at node entry / exit to
avoid Value::Ext(Box::new(...)) boilerplate.
Sourcepub fn from_partition(p: Partition) -> Self
pub fn from_partition(p: Partition) -> Self
Wrap a Partition as a Polydat Value::Ext.
Sourcepub fn from_partition_spec(s: PartitionSpec) -> Self
pub fn from_partition_spec(s: PartitionSpec) -> Self
Wrap a PartitionSpec as a Polydat Value::Ext.
Sourcepub fn from_partition_list(parts: Vec<Partition>) -> Self
pub fn from_partition_list(parts: Vec<Partition>) -> Self
Wrap a Vec<Partition> as a Polydat Value::Ext via
PartitionList. Use this when a wire needs to carry
the whole resolved list (e.g. the <param>.partitions
projection).
Sourcepub fn as_partition(&self) -> Option<&Partition>
pub fn as_partition(&self) -> Option<&Partition>
Downcast to a Partition reference. Returns None if
the value isn’t a partition.
Sourcepub fn as_partition_spec(&self) -> Option<&PartitionSpec>
pub fn as_partition_spec(&self) -> Option<&PartitionSpec>
Downcast to a PartitionSpec reference. Returns None
if the value isn’t a spec.
Sourcepub fn as_partition_list(&self) -> Option<&PartitionList>
pub fn as_partition_list(&self) -> Option<&PartitionList>
Downcast to a PartitionList reference. Returns None
if the value isn’t a partition list.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Value
impl !UnwindSafe for Value
impl Freeze for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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