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 failsFunction: The type implementingFunctionDatafor function metadataFunctionIter: Iterator over the functions this interface declaresResourceIter: Iterator over the resource types this interface declares
Required Associated Types§
Sourcetype Id: Clone + Hash + Eq + Display + Debug
type Id: Clone + Hash + Eq + Display + Debug
A type used as a unique identifier for an interface
Sourcetype Function: FunctionData + Clone + Send + Sync + 'static
type Function: FunctionData + Clone + Send + Sync + 'static
Function metadata type implementing FunctionData.
Sourcetype FunctionIter<'a>: IntoIterator<Item = &'a Self::Function>
where
Self: 'a
type FunctionIter<'a>: IntoIterator<Item = &'a Self::Function> where Self: 'a
Iterator over functions declared by this interface.
Sourcetype ResourceIter<'a>: IntoIterator<Item = &'a String>
where
Self: 'a
type ResourceIter<'a>: IntoIterator<Item = &'a String> where Self: 'a
Iterator over resource type names declared by this interface.
Required Methods§
Sourcefn id(&self) -> Result<&Self::Id, Self::Error>
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.
Sourcefn cardinality(&self) -> Result<&InterfaceCardinality, Self::Error>
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.
Sourcefn package_name(&self) -> Result<&str, Self::Error>
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.
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.