pub enum PortType {
Show 34 variants
U64,
F64,
U32,
I32,
I64,
F32,
U8,
I8,
U16,
I16,
F16,
U128,
I128,
Reg128,
RegI8x16,
RegI16x8,
RegI32x4,
RegI64x2,
RegF16x8,
RegF32x4,
RegF64x2,
Bool,
Str,
Bytes,
Json,
Ext,
Handle,
VecF32,
VecI32,
VecF64,
VecI64,
VecF16,
VecI16,
VecI8,
}Expand description
Compile-time type tag for a port on a Polydat node.
Narrow types and runtime storage:
PortType includes narrow integer and float variants (U32, I32,
I64, F32) that have no corresponding Value variant. At runtime,
narrow values are stored inside Value::U64 (for integers) or
Value::F64 (for f32), with the assumption that the bits fit:
u32→ zero-extended inValue::U64i32→ sign-extended or bit-reinterpreted inValue::U64i64→ bit-reinterpreted inValue::U64f32→ losslessly widened inValue::F64
The narrow PortType variants exist for compile-time type
checking and auto-adapter insertion (U32ToU64, F32ToF64).
P2/P3 compiled kernels use flat u64 buffers where this packing
is natural. The Value enum stays small — no combinatorial
explosion of narrow variant types.
Every input and output port declares its PortType. The assembler
uses these to validate wiring and auto-insert type adapters (e.g.,
u64 → f64 widening). At runtime, the corresponding Value
variant is used.
Widening rules (auto-inserted by the assembler):
U32 → U64,I32 → I64,F32 → F64(lossless widening)U64 → F64(lossless for values < 2^53)Bool → U64(true=1, false=0)- Any type →
Str(via display conversion)
Narrowing is never implicit — use explicit cast functions.
Variants§
U64
64-bit unsigned integer. The primary numeric type.
F64
64-bit IEEE 754 float. Used for math, distributions, noise.
U32
32-bit unsigned integer. Widens to U64 automatically.
I32
32-bit signed integer. Widens to I64 automatically.
I64
64-bit signed integer.
F32
32-bit IEEE 754 float. Widens to F64 automatically.
U8
8-bit unsigned integer (cranelift I8 lane, unsigned
interpretation). Zero-extended in Value::U64; widens to
U64 automatically.
I8
8-bit signed integer (cranelift I8 lane, signed
interpretation). Sign-extended in Value::I64; widens to
I64 automatically.
U16
16-bit unsigned integer (cranelift I16 lane, unsigned
interpretation). Zero-extended in Value::U64; widens to
U64 automatically.
I16
16-bit signed integer (cranelift I16 lane, signed
interpretation). Sign-extended in Value::I64; widens to
I64 automatically.
F16
16-bit IEEE 754-2008 binary16 float (cranelift F16).
Carried as its bit pattern in Value::U64 (low 16 bits),
the same stuffing convention as F32; widens to F32/F64
automatically (every f16 is exactly representable in both).
U128
128-bit unsigned integer (cranelift I128, unsigned
interpretation). Real Value::U128 two-limb carrier — a
128-bit value cannot ride a 64-bit slot. Interpreter-only.
I128
128-bit signed integer (cranelift I128, signed
interpretation). Same carrier story as U128.
Reg128
128-bit SIMD register word, raw view — the full word as algorithm-defined buffer state (heterogeneous lane roles). Free bitcast to/from every lane-typed view.
RegI8x16
Register word viewed as 16 × i8 lanes.
RegI16x8
Register word viewed as 8 × i16 lanes.
RegI32x4
Register word viewed as 4 × i32 lanes.
RegI64x2
Register word viewed as 2 × i64 lanes.
RegF16x8
Register word viewed as 8 × f16 lanes.
RegF32x4
Register word viewed as 4 × f32 lanes.
RegF64x2
Register word viewed as 2 × f64 lanes.
Bool
Boolean (true/false). Widens to U64 (1/0).
Str
Heap-allocated string. Any type auto-converts to Str.
Bytes
Raw byte buffer.
Json
Structured JSON value.
Ext
Adapter-contributed reflected type (e.g., CQL UUID).
Handle
Type-erased Arc handle to a resolved resource (dataset,
prepared statement, …). The producer node populates an
Arc<dyn Any + Send + Sync>; the consumer node downcasts to
the concrete type via Value::as_handle::<T>().
VecF32
Typed f32 vector slice (Arc<[f32]>). Bound natively by
adapters that understand [f32] (CQL vector<float, N>).
VecI32
Typed i32 vector slice (Arc<[i32]>).
VecF64
Typed f64 vector slice (Arc<[f64]>). Bound natively
for CQL vector<double, N>.
VecI64
Typed i64 vector slice (Arc<[i64]>). Bound natively
for CQL vector<bigint, N>.
VecF16
Typed half-precision float vector (Arc<[half::f16]>).
Bound natively for CQL vector<half_float, N>-style
columns; stays at f16 on the wire so embeddings stored
as 16-bit floats don’t widen to f32 at the boundary.
VecI16
Typed i16 vector slice (Arc<[i16]>). Bound natively
for CQL vector<smallint, N>.
VecI8
Typed i8 vector slice (Arc<[i8]>). Completes the
cranelift lane family; CQL vector<tinyint, N>.
Implementations§
Source§impl PortType
impl PortType
Sourcepub fn to_keyword(&self) -> &'static str
pub fn to_keyword(&self) -> &'static str
The canonical lowercase keyword for this PortType.
This is the single source of truth for the str↔PortType
mapping used by every synthesizer and parser in the
workspace — synthesized polydat source (extern <name>: <keyword>), the workload-author {name:<keyword>} lvalue
spec, and reverse parsing via Self::from_keyword.
Inverse of Self::from_keyword.
Exhaustive over the enum — adding a new PortType variant
is a compile error here, forcing the addition of its
canonical keyword and the round-trip closure to update.
Sourcepub fn from_keyword(name: &str) -> Option<Self>
pub fn from_keyword(name: &str) -> Option<Self>
Parse a polydat type keyword into a PortType.
Inverse of Self::to_keyword: accepts every keyword
that to_keyword emits, plus a small set of legacy aliases
("String", "Json", "Ext") that survive in older
hand-written workload source. Returns None for any
unrecognized keyword so callers can surface a loud
diagnostic rather than silently coercing to a default.
Used by the DSL extern <name>: <keyword> parser
(polydat/src/dsl/compile.rs). Round-trips cleanly with
any source to_keyword emits.
Sourcepub fn from_workload_name(name: &str) -> Option<Self>
pub fn from_workload_name(name: &str) -> Option<Self>
Workload-author-facing parser for the {name:<keyword>}
lvalue-spec surface. Strict subset of Self::from_keyword
— handle, ext, and none are rejected because they’re
internal-only types a workload author should never assert.
Returns None for any unrecognized name; the caller
surfaces the unknown spec as a workload-shape diagnostic.
Trait Implementations§
impl Copy for PortType
impl Eq for PortType
impl StructuralPartialEq for PortType
Auto Trait Implementations§
impl Freeze for PortType
impl RefUnwindSafe for PortType
impl Send for PortType
impl Sync for PortType
impl Unpin for PortType
impl UnsafeUnpin for PortType
impl UnwindSafe for PortType
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.