Skip to main content

PluginHost

Struct PluginHost 

Source
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

Source

pub fn new() -> Self

Source

pub fn with_loader(self, loader: Arc<dyn PluginLoader>) -> Self

Add a loader for a custom runtime (e.g. wasm).

Source

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.

Source

pub fn with_trusted<I, S>(self, names: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Trust several plugins by name (see PluginHost::trust).

Source

pub fn load(&mut self, manifest_path: &Path) -> Result<PluginInfo, PluginError>

Load the plugin whose manifest is at manifest_path.

Source

pub fn load_dir(&mut self, dir: &Path) -> Result<Vec<PluginInfo>, PluginError>

Load a plugin directory, or every plugin directly inside dir.

Source

pub fn load_dirs( &mut self, paths: &[PathBuf], ) -> Result<Vec<PluginInfo>, PluginError>

Load every plugin found under paths (see crate::discover).

Source

pub fn add(&mut self, plugin: LoadedManifest) -> Result<PluginInfo, PluginError>

Add an already-parsed plugin.

Source

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.

Source

pub fn plugins(&self) -> Vec<PluginInfo>

Loaded plugins.

Source

pub fn descriptors(&self) -> Vec<NodeDescriptor>

Descriptors of every plugin node (for catalogs).

Source

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.

Source

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).

Trait Implementations§

Source§

impl Debug for PluginHost

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PluginHost

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more