pub struct PluginHost { /* private fields */ }Expand description
Loads plugins and registers them into a Registry and ToolRegistry.
Permissions in a manifest are requests. Plaintext secrets and HTTP bearer
tokens taken from the host environment are only granted to plugins the
operator trusts by name (PluginHost::trust); a manifest cannot grant them
to itself.
Implementations§
Source§impl PluginHost
impl PluginHost
pub fn new() -> Self
Sourcepub fn with_loader(self, loader: Arc<dyn PluginLoader>) -> Self
pub fn with_loader(self, loader: Arc<dyn PluginLoader>) -> Self
Add a loader for a custom runtime (e.g. wasm).
Sourcepub fn trust(self, name: impl Into<String>) -> Self
pub fn trust(self, name: impl Into<String>) -> Self
Trust the plugin named name: it may receive plaintext secrets and HTTP
bearer tokens when its manifest requests them. Call before loading.
Sourcepub fn with_trusted<I, S>(self, names: I) -> Self
pub fn with_trusted<I, S>(self, names: I) -> Self
Trust several plugins by name (see PluginHost::trust).
Sourcepub fn load(&mut self, manifest_path: &Path) -> Result<PluginInfo, PluginError>
pub fn load(&mut self, manifest_path: &Path) -> Result<PluginInfo, PluginError>
Load the plugin whose manifest is at manifest_path.
Sourcepub fn load_dir(&mut self, dir: &Path) -> Result<Vec<PluginInfo>, PluginError>
pub fn load_dir(&mut self, dir: &Path) -> Result<Vec<PluginInfo>, PluginError>
Load a plugin directory, or every plugin directly inside dir.
Sourcepub fn load_dirs(
&mut self,
paths: &[PathBuf],
) -> Result<Vec<PluginInfo>, PluginError>
pub fn load_dirs( &mut self, paths: &[PathBuf], ) -> Result<Vec<PluginInfo>, PluginError>
Load every plugin found under paths (see crate::discover).
Sourcepub fn add(&mut self, plugin: LoadedManifest) -> Result<PluginInfo, PluginError>
pub fn add(&mut self, plugin: LoadedManifest) -> Result<PluginInfo, PluginError>
Add an already-parsed plugin.
Sourcepub fn add_with_transport(
&mut self,
plugin: LoadedManifest,
transport: Arc<dyn Transport>,
) -> Result<PluginInfo, PluginError>
pub fn add_with_transport( &mut self, plugin: LoadedManifest, transport: Arc<dyn Transport>, ) -> Result<PluginInfo, PluginError>
Add a plugin reachable over an existing transport (e.g. an in-process
crate::IoTransport). plugin.manifest.runtime is ignored.
Sourcepub fn plugins(&self) -> Vec<PluginInfo>
pub fn plugins(&self) -> Vec<PluginInfo>
Loaded plugins.
Sourcepub fn descriptors(&self) -> Vec<NodeDescriptor>
pub fn descriptors(&self) -> Vec<NodeDescriptor>
Descriptors of every plugin node (for catalogs).
Sourcepub async fn refresh(&mut self) -> Result<(), PluginError>
pub async fn refresh(&mut self) -> Result<(), PluginError>
Start every process/HTTP plugin and apply node and tool lists returned by
initialize (when a plugin returns them). Call before PluginHost::register.
Sourcepub fn register(
&self,
registry: &mut Registry,
tools: &mut ToolRegistry,
) -> Result<(), PluginError>
pub fn register( &self, registry: &mut Registry, tools: &mut ToolRegistry, ) -> Result<(), PluginError>
Register every plugin’s nodes into registry and tools into tools.
Fails on node kinds that are already registered (plugins never replace
built-in or other plugins’ nodes).