Skip to main content

Plugin

Trait Plugin 

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

    // Required methods
    fn create<'life0, 'life1, 'async_trait>(
        context: &'life0 PluginInitContext<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<Self, String>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: '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<'life0, 'life1, 'async_trait>( context: &'life0 PluginInitContext<'life1>, ) -> Pin<Box<dyn Future<Output = Result<Self, String>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait, 'life1: '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: Configuration in Synapto plugins is entirely optional. If your plugin requires no configuration, simply do not define a config struct and do not call context.config()?.

If you do define a config struct: when calling context.config()? to extract your configuration, ensure any optional fields in your struct are marked with #[serde(default)]. Otherwise, omitted fields in the config file will cause strict deserialization errors. Alternatively, use context.optional_config()? to allow the entire config block to be safely omitted.

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§