pub enum TypeRepr {
Unit,
Bool,
Int,
Float,
String,
List {
element: Box<TypeRepr>,
},
Option {
inner: Box<TypeRepr>,
},
Result {
ok: Box<TypeRepr>,
err: Box<TypeRepr>,
},
Enum {
name: String,
variants: Vec<EnumVariant>,
},
Schema {
schema: Box<Schema>,
},
Closure {
params: Vec<TypeRepr>,
ret: Box<TypeRepr>,
},
}Expand description
Logical type description used by canonical serialisation.
This is not the parser’s TypeNode: the parser shape carries
source ranges, doc comments, and parsed-but-unresolved generic
argument references, none of which belong in an ABI hash. The
canonical form is a structural snapshot that strips presentation
metadata and inlines nested schemas.
Variants mirror the v1 binary layout’s leaf-type table. Tuple
shapes are represented as tuple schemas (Schema::is_tuple = true);
future leaf/container layout shapes such as Bytes would need a new
variant here so the hash distinguishes the new shape.
Variants§
Unit
Internal unit slot. New source schemas should use Option<T>
or T? for absence instead of producing this type.
Bool
Bool — a 0/1 byte.
Int
Int — a signed 64-bit integer.
Float
Float — an IEEE-754 double.
String
String — UTF-8 bytes with a u32 length prefix.
List
List<T> — variable-length sequence over element.
Option
Option<T> — tag + payload union with two arms.
Result
Result<T, E> — tag + payload union with two arms.
Enum
User-defined Rust-like #enum Name { ... }. The binary ABI is a
variant record: one tag byte plus an optional payload slot. Struct
and tuple variant payloads are represented as ordinary schemas, with
tuple payloads marked by EnumVariant::is_tuple.
Schema
Inline reference to a named nested schema. The hash flattens the nested structure rather than recording the name, so two schemas with identical structural shape collapse to the same digest regardless of declaration site.
Closure
Phase F.2 (W7 closure-as-value boundary) — first-class closure
value. The variant records the closure’s user-visible signature
(params declaration order, ret); the schema digest treats it
as a structural shape so two anonymous closure fields with the
same (params, ret) collapse to the same hash regardless of
declaration site.
The runtime representation is a scratch-heap pointer-indirect
8-byte handle ([fn_table_idx: u32 LE][captures_ptr: u32 LE]);
see relon_ir::IrType::Closure for the wasm-side layout. The
canonical form intentionally avoids carrying capture metadata —
captures are an implementation detail of the lambda’s closure
conversion, not part of its ABI-visible type.
Layout integration is not wired in this milestone: any
TypeRepr::Closure reaching SchemaLayout::offsets_for surfaces
as LayoutError::UnsupportedTypeInLayoutV1 so the cross-boundary
dangle the binary handshake would otherwise see stays guarded.
Closure-typed fields are only valid as in-function intermediate
values (let-bindings, dict-field caches the lowering pass
owns) — never at a host-visible #main boundary.
Implementations§
Source§impl TypeRepr
impl TypeRepr
Sourcepub fn enum_variant_by_tag(&self, tag: u8) -> Option<&EnumVariant>
pub fn enum_variant_by_tag(&self, tag: u8) -> Option<&EnumVariant>
Return a custom enum variant by ABI tag.
Sourcepub fn enum_variant_by_name(&self, variant_name: &str) -> Option<&EnumVariant>
pub fn enum_variant_by_name(&self, variant_name: &str) -> Option<&EnumVariant>
Return a custom enum variant by source name.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TypeRepr
impl<'de> Deserialize<'de> for TypeRepr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TypeRepr
impl StructuralPartialEq for TypeRepr
Auto Trait Implementations§
impl Freeze for TypeRepr
impl RefUnwindSafe for TypeRepr
impl Send for TypeRepr
impl Sync for TypeRepr
impl Unpin for TypeRepr
impl UnsafeUnpin for TypeRepr
impl UnwindSafe for TypeRepr
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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