Skip to main content

InterfaceData

Trait InterfaceData 

Source
pub trait InterfaceData: Sized {
    type Id: Clone + Hash + Eq + Display + Debug;
    type Error: Error;
    type Function: FunctionData + Clone + Send + Sync + 'static;
    type FunctionIter<'a>: IntoIterator<Item = &'a Self::Function>
       where Self: 'a;
    type ResourceIter<'a>: IntoIterator<Item = &'a String>
       where Self: 'a;

    // Required methods
    fn id(&self) -> Result<&Self::Id, Self::Error>;
    fn cardinality(&self) -> Result<&InterfaceCardinality, Self::Error>;
    fn package_name(&self) -> Result<&str, Self::Error>;
    fn functions(&self) -> Result<Self::FunctionIter<'_>, Self::Error>;
    fn resources(&self) -> Result<Self::ResourceIter<'_>, Self::Error>;
}
Expand description

Trait for accessing interface metadata from a user-defined source.

Implement this trait to define how interface specifications are loaded. wasm_link uses this trait to discover interface contracts when linking plugins together.

§Associated Types

  • Id: Unique identifier type for interfaces (e.g., String, &'static str, Uuid)
  • Error: The error type returned when metadata access fails
  • Function: The type implementing FunctionData for function metadata
  • FunctionIter: Iterator over the functions this interface declares
  • ResourceIter: Iterator over the resource types this interface declares

Required Associated Types§

Source

type Id: Clone + Hash + Eq + Display + Debug

A type used as a unique identifier for an interface

Source

type Error: Error

Error type for metadata access failures.

Source

type Function: FunctionData + Clone + Send + Sync + 'static

Function metadata type implementing FunctionData.

Source

type FunctionIter<'a>: IntoIterator<Item = &'a Self::Function> where Self: 'a

Iterator over functions declared by this interface.

Source

type ResourceIter<'a>: IntoIterator<Item = &'a String> where Self: 'a

Iterator over resource type names declared by this interface.

Required Methods§

Source

fn id(&self) -> Result<&Self::Id, Self::Error>

Returns the unique identifier for this interface.

§Errors

Implementations may fail if the underlying data source is unavailable.

Source

fn cardinality(&self) -> Result<&InterfaceCardinality, Self::Error>

Returns how many plugins may/must implement this interface.

§Errors

Implementations may fail if the underlying data source is unavailable.

Source

fn package_name(&self) -> Result<&str, Self::Error>

Returns the WIT package name for this interface.

§Errors

Implementations may fail if the underlying data source is unavailable.

Source

fn functions(&self) -> Result<Self::FunctionIter<'_>, Self::Error>

Returns the functions exported by this interface.

§Errors

Implementations may fail if the underlying data source is unavailable.

Source

fn resources(&self) -> Result<Self::ResourceIter<'_>, Self::Error>

Returns the resource types defined by this interface.

§Errors

Implementations may fail if the underlying data source is unavailable.

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§