Skip to main content

Module polyfill

Module polyfill 

Source
Expand description

Polyfill edge adapters covering every cell of the type matrix from polydat/docs/design/type_system.md §3 that has a sensible conversion.

Existing widening + obvious coercions live in crate::library::convert. This module fills in the rest:

  • Numeric narrowings (U64→U32, I64→I32, F64→F32, …) with range-check panic on out-of-range.
  • Bool↔every numeric beyond Bool↔U64.
  • String parsers (Str→{U32, I32, I64, F32, Bytes, Json, VecF32, VecI32}) — boundary-only because they can panic on unparseable input.
  • Bytes serdes with little-endian byte order for numeric and vector targets, lowercase hex for Bytes↔Str.
  • Json serdes with try-parse-or-error-wrap for Str→Json and shape-validating parses elsewhere.
  • Vec↔{Str, Bytes, Json} serdes; VecF32↔VecI32 casts.

See polydat/src/compile/assembly.rs::auto_adapter and ::boundary_adapter for catalog registration. The split is by failure mode: anything that can panic on input the assembler couldn’t verify (range, parse, shape) lives in boundary_adapter only; lossless widenings live in both via the boundary_adapter superset relation.

Every cell is authored as an individual #[polydat_node] free function per SRD-80b §S14 — the macro emits the matching PascalCase struct (e.g. __u64_to_i32U64ToI32), the impl PolydatNode, and the inventory registration. The __ prefix on the function identifier carries through to the DSL/NodeMeta name, which is the convention assembly’s adapter-detection passes use to identify auto-inserted type-coercion bridges (name.starts_with("__")).

Structs§

BoolToBytes
The __bool_to_bytes node.
BoolToF32
The __bool_to_f32 node.
BoolToF64
The __bool_to_f64 node.
BoolToI32
The __bool_to_i32 node.
BoolToI64
The __bool_to_i64 node.
BoolToJson
The __bool_to_json node.
BoolToU32
The __bool_to_u32 node.
BytesToBool
The __bytes_to_bool node.
BytesToF32
The __bytes_to_f32 node.
BytesToF64
The __bytes_to_f64 node.
BytesToI32
The __bytes_to_i32 node.
BytesToI64
The __bytes_to_i64 node.
BytesToJson
The __bytes_to_json node.
BytesToStr
The __bytes_to_str node.
BytesToU32
The __bytes_to_u32 node.
BytesToU64
The __bytes_to_u64 node.
BytesToVecF32
The __bytes_to_vec_f32 node.
BytesToVecI32
The __bytes_to_vec_i32 node.
F32ToBool
The __f32_to_bool node.
F32ToBytes
The __f32_to_bytes node.
F32ToI32
The __f32_to_i32 node.
F32ToI64
The __f32_to_i64 node.
F32ToJson
The __f32_to_json node.
F32ToU32
The __f32_to_u32 node.
F32ToU64
The __f32_to_u64 node.
F64ToBool
The __f64_to_bool node.
F64ToBytes
The __f64_to_bytes node.
F64ToF32
The __f64_to_f32 node.
F64ToI32
The __f64_to_i32 node.
F64ToI64
The __f64_to_i64 node.
F64ToJson
The __f64_to_json node.
F64ToU32
The __f64_to_u32 node.
F64ToU64Checked
The __f64_to_u64_checked node.
I32ToBool
The __i32_to_bool node.
I32ToBytes
The __i32_to_bytes node.
I32ToF32
The __i32_to_f32 node.
I32ToJson
The __i32_to_json node.
I32ToU32
The __i32_to_u32 node.
I32ToU64
The __i32_to_u64 node.
I64ToBool
The __i64_to_bool node.
I64ToBytes
The __i64_to_bytes node.
I64ToF32
The __i64_to_f32 node.
I64ToI32
The __i64_to_i32 node.
I64ToJson
The __i64_to_json node.
I64ToU32
The __i64_to_u32 node.
I64ToU64
The __i64_to_u64 node.
JsonToBool
The __json_to_bool node.
JsonToBytes
The __json_to_bytes node.
JsonToF32
The __json_to_f32 node.
JsonToF64
The __json_to_f64 node.
JsonToI32
The __json_to_i32 node.
JsonToI64
The __json_to_i64 node.
JsonToU32
The __json_to_u32 node.
JsonToU64
The __json_to_u64 node.
JsonToVecF32
The __json_to_vec_f32 node.
JsonToVecI32
The __json_to_vec_i32 node.
StrToBytes
The __str_to_bytes node.
StrToF32
The __str_to_f32 node.
StrToI32
The __str_to_i32 node.
StrToI64
The __str_to_i64 node.
StrToJson
The __str_to_json node.
StrToU32
The __str_to_u32 node.
StrToVecF32
The __str_to_vec_f32 node.
StrToVecI32
The __str_to_vec_i32 node.
U32ToBool
The __u32_to_bool node.
U32ToBytes
The __u32_to_bytes node.
U32ToF32
The __u32_to_f32 node.
U32ToI32
The __u32_to_i32 node.
U32ToJson
The __u32_to_json node.
U64ToBytes
The __u64_to_bytes node.
U64ToF32
The __u64_to_f32 node.
U64ToI32
The __u64_to_i32 node.
U64ToI64
The __u64_to_i64 node.
U64ToJson
The __u64_to_json node.
U64ToU32
The __u64_to_u32 node.
VecF32ToBytes
The __vec_f32_to_bytes node.
VecF32ToJson
The __vec_f32_to_json node.
VecF32ToStr
The __vec_f32_to_str node.
VecF32ToVecI32
The __vec_f32_to_vec_i32 node.
VecI32ToBytes
The __vec_i32_to_bytes node.
VecI32ToJson
The __vec_i32_to_json node.
VecI32ToStr
The __vec_i32_to_str node.
VecI32ToVecF32
The __vec_i32_to_vec_f32 node.