Skip to main content

TypeRepr

Enum TypeRepr 

Source
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.

Fields

§element: Box<TypeRepr>

Element type.

§

Option

Option<T> — tag + payload union with two arms.

Fields

§inner: Box<TypeRepr>

Some payload type.

§

Result

Result<T, E> — tag + payload union with two arms.

Fields

§ok: Box<TypeRepr>

Ok payload type.

§err: Box<TypeRepr>

Err payload type.

§

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.

Fields

§name: String

Enum type name.

§variants: Vec<EnumVariant>

Variants in declaration/tag order.

§

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.

Fields

§schema: Box<Schema>

Recursive canonical form of the nested schema.

§

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.

Fields

§params: Vec<TypeRepr>

User-visible parameter types in declaration order. Carries nested TypeRepr so a closure-returning closure ((Int) => (Int) => Int) hashes as a distinct shape from a flat (Int, Int) => Int.

§ret: Box<TypeRepr>

Return type. Single value (no tuples) — matches the wasm call_indirect signature codegen emits today.

Implementations§

Source§

impl TypeRepr

Source

pub fn enum_variant_by_tag(&self, tag: u8) -> Option<&EnumVariant>

Return a custom enum variant by ABI tag.

Source

pub fn enum_variant_by_name(&self, variant_name: &str) -> Option<&EnumVariant>

Return a custom enum variant by source name.

Trait Implementations§

Source§

impl Clone for TypeRepr

Source§

fn clone(&self) -> TypeRepr

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 Debug for TypeRepr

Source§

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

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

impl<'de> Deserialize<'de> for TypeRepr

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TypeRepr

Source§

impl PartialEq for TypeRepr

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TypeRepr

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TypeRepr

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.