Skip to main content

RexAdt

Trait RexAdt 

Source
pub trait RexAdt: RexType {
    // Required method
    fn rex_adt_decl() -> Result<AdtDecl, TypeError>;

    // Provided method
    fn rex_adt_family() -> Result<Vec<AdtDecl>, TypeError> { ... }
}
Expand description

Rust-side declaration metadata for a type represented as a Rex ADT.

RexAdt extends RexType for Rust structs and enums that have a named Rex algebraic data type declaration. The engine and module APIs use this trait to register constructors and type declarations before Rex code constructs or consumes values of the Rust type.

Most embedders should derive this with #[derive(rex::Rex)]. Manual implementations are useful for hand-written bridges or types whose Rex shape differs from their Rust fields.

Required Methods§

Source

fn rex_adt_decl() -> Result<AdtDecl, TypeError>

Return the single Rex ADT declaration for Self.

This should describe only the type represented by Self; dependencies belong in RexType::collect_rex_family.

Provided Methods§

Source

fn rex_adt_family() -> Result<Vec<AdtDecl>, TypeError>

Return the ADT family needed to register Self.

The default implementation delegates to RexType::collect_rex_family. Derived implementations of collect_rex_family include dependencies and Self; manual implementations can override this method when they need a custom family collection strategy.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§