pub trait PluginData:
Sized
+ Send
+ PluginCtxView {
type Id: Clone + Hash + Eq + Debug + Send + Sync;
type InterfaceId: Clone + Hash + Eq + Display;
type Error: Error;
type SocketIter<'a>: IntoIterator<Item = &'a Self::InterfaceId>
where Self: 'a;
// Required methods
fn id(&self) -> Result<&Self::Id, Self::Error>;
fn plug(&self) -> Result<&Self::InterfaceId, Self::Error>;
fn sockets(&self) -> Result<Self::SocketIter<'_>, Self::Error>;
fn component(&self, engine: &Engine) -> Result<Component, Self::Error>;
}Expand description
Trait for accessing plugin metadata and WASM binaries from a user-defined source.
Implement this trait to define how plugins are discovered, how their metadata is read, and how their WASM binaries are loaded.
Each plugin declares:
- A plug: the interface it implements (what it exports)
- Zero or more sockets: interfaces it depends on (what it imports)
During loading, the framework uses this information to build the dependency graph and link plugins together.
§Associated Types
Id: Unique identifier type for plugins (e.g.,String,Uuid,PathBuf)InterfaceId: Must match theIdtype used by yourInterfaceDataimplementationError: The error type returned when metadata access or compilation failsSocketIter: Iterator over the interface IDs this plugin depends on
Required Associated Types§
Sourcetype Id: Clone + Hash + Eq + Debug + Send + Sync
type Id: Clone + Hash + Eq + Debug + Send + Sync
A type used as a unique identifier for a plugin
Sourcetype InterfaceId: Clone + Hash + Eq + Display
type InterfaceId: Clone + Hash + Eq + Display
A type used as a unique identifier for an interface
Sourcetype SocketIter<'a>: IntoIterator<Item = &'a Self::InterfaceId>
where
Self: 'a
type SocketIter<'a>: IntoIterator<Item = &'a Self::InterfaceId> where Self: 'a
Iterator over interface IDs this plugin depends on (its sockets).
Required Methods§
Sourcefn id(&self) -> Result<&Self::Id, Self::Error>
fn id(&self) -> Result<&Self::Id, Self::Error>
Returns this plugin’s unique identifier.
§Errors
Implementations may fail if the underlying data source is unavailable.
Sourcefn plug(&self) -> Result<&Self::InterfaceId, Self::Error>
fn plug(&self) -> Result<&Self::InterfaceId, Self::Error>
Returns the interface ID that this plugin implements (its plug).
The plug declares which interface this plugin provides an implementation for. The plugin must export all functions declared by this interface.
§Errors
Implementations may fail if the underlying data source is unavailable.
Sourcefn sockets(&self) -> Result<Self::SocketIter<'_>, Self::Error>
fn sockets(&self) -> Result<Self::SocketIter<'_>, Self::Error>
Returns the interface IDs that this plugin depends on (its sockets).
Each socket is an interface the plugin expects to call into. During linking, these calls are wired to the plugin(s) implementing each interface.
§Errors
Implementations may fail if the underlying data source is unavailable.
Sourcefn component(&self, engine: &Engine) -> Result<Component, Self::Error>
fn component(&self, engine: &Engine) -> Result<Component, Self::Error>
Compiles this plugin’s WASM binary into a wasmtime Component.
Called during PluginTree::load to compile the plugin. The implementation
is responsible for locating and reading the WASM binary.
§Errors
May fail due to I/O errors reading the WASM source, or wasmtime compilation errors if the binary is invalid or incompatible.
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.