Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin:
    Send
    + Sync
    + 'static {
    const CAPABILITY: Option<&'static str> = None;

    // Required methods
    fn create<'async_trait>(
        context: PluginContext,
    ) -> Pin<Box<dyn Future<Output = Result<Self, String>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait;
    fn register<R: PluginRegistry + ?Sized>(self: Arc<Self>, registry: &mut R)
       where Self: Sized;
}

Provided Associated Constants§

Source

const CAPABILITY: Option<&'static str> = None

Compile-time semantic description of this plugin’s capability for the LLM.

Required Methods§

Source

fn create<'async_trait>( context: PluginContext, ) -> Pin<Box<dyn Future<Output = Result<Self, String>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,

This is the method for instantiating plugins, allowing them to await their database connections (via context.store::<S>().await) before returning.

Note on Configuration: When calling context.config()? to extract your configuration struct, ensure any optional fields in your struct are marked with #[serde(default)]. Otherwise, omitted fields in the config file will cause strict deserialization errors.

Source

fn register<R: PluginRegistry + ?Sized>(self: Arc<Self>, registry: &mut R)
where Self: Sized,

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§