Skip to main content

PortType

Enum PortType 

Source
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 in Value::U64
  • i32 → sign-extended or bit-reinterpreted in Value::U64
  • i64 → bit-reinterpreted in Value::U64
  • f32 → losslessly widened in Value::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

Source

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.

Source

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.

Source

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_keywordhandle, 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§

Source§

impl Clone for PortType

Source§

fn clone(&self) -> PortType

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 Copy for PortType

Source§

impl Debug for PortType

Source§

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

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

impl Display for PortType

Source§

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

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

impl Eq for PortType

Source§

impl Hash for PortType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PortType

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PortType

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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.