Skip to main content

DynamicComponentContract

Trait DynamicComponentContract 

Source
pub trait DynamicComponentContract: 'static {
    type Props: Serialize + for<'de> Deserialize<'de> + Clone + PartialEq + 'static;
    type Event: Serialize + for<'de> Deserialize<'de> + Clone + 'static;

    const INTERFACE_ID: &'static str;
    const INTERFACE_VERSION: u32;
    const STATE_SCHEMA_VERSION: u32;

    // Required methods
    fn wit_definition() -> &'static str;
    fn fallback_spec(props: &Self::Props) -> DynamicNodeSpec;
    fn decode_action(
        action: &DynamicActionEvent,
        props: &Self::Props,
    ) -> Option<Self::Event>;
}
Expand description

Compile-time strongly-typed dynamic component interface shared by Wasm Component (WIT) and Declarative Data channels.

Required Associated Constants§

Source

const INTERFACE_ID: &'static str

Canonical interface identifier verified against pinned release artifacts before activation.

Source

const INTERFACE_VERSION: u32

Interface contract version independent of implementation and state schema versions.

Source

const STATE_SCHEMA_VERSION: u32

Expected component local state schema version.

Required Associated Types§

Source

type Props: Serialize + for<'de> Deserialize<'de> + Clone + PartialEq + 'static

Strongly-typed input properties validated by the Rust compiler at every call site.

Source

type Event: Serialize + for<'de> Deserialize<'de> + Clone + 'static

Strongly-typed output events validated by the Rust compiler on every handler.

Required Methods§

Source

fn wit_definition() -> &'static str

Returns the WIT interface source defining this component contract.

§Returns
  • &'static str - Canonical WIT definition.
Source

fn fallback_spec(props: &Self::Props) -> DynamicNodeSpec

Builds the compiled native fallback UI tree used before any remote release is active.

§Arguments
  • &Self::Props - Strongly-typed component properties.
§Returns
  • DynamicNodeSpec - Fallback declarative UI subtree.
Source

fn decode_action( action: &DynamicActionEvent, props: &Self::Props, ) -> Option<Self::Event>

Decodes a dynamic UI control action back into a strongly-typed Self::Event.

§Arguments
  • &DynamicActionEvent - Raw interaction event from a dynamic slot control.
  • &Self::Props - Active typed properties of the slot.
§Returns
  • Option<Self::Event> - Typed event when recognized by this contract.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl DynamicComponentContract for ProductCardContract

Reference strongly-typed dynamic component contract implementation for ProductCardContract.

Source§

const INTERFACE_ID: &'static str = PRODUCT_CARD_INTERFACE_ID

Source§

const INTERFACE_VERSION: u32 = PRODUCT_CARD_INTERFACE_VERSION

Source§

const STATE_SCHEMA_VERSION: u32 = PRODUCT_CARD_STATE_SCHEMA_VERSION

Source§

type Props = ProductCardProps

Source§

type Event = ProductCardEvent