pub struct Plugin { /* private fields */ }Expand description
A plugin: a set of node kinds and tools.
Implementations§
Source§impl Plugin
impl Plugin
pub fn new(name: impl Into<String>) -> Self
Sourcepub fn node<F, Fut, O>(self, kind: impl Into<String>, handler: F) -> Self
pub fn node<F, Fut, O>(self, kind: impl Into<String>, handler: F) -> Self
Register a node kind handler.
Sourcepub fn describe(self, descriptor: Value) -> Self
pub fn describe(self, descriptor: Value) -> Self
Publish a node descriptor from initialize (optional; the manifest is
usually enough). descriptor follows the graphrt node catalog format.
Sourcepub fn tool<F, Fut>(self, spec: Value, handler: F) -> Selfwhere
F: Fn(ToolCall) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ToolResult, PluginError>> + Send + 'static,
pub fn tool<F, Fut>(self, spec: Value, handler: F) -> Selfwhere
F: Fn(ToolCall) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ToolResult, PluginError>> + Send + 'static,
Register a tool. spec is {name, description, parameters}.
Sourcepub async fn serve_stdio(self) -> Result<()>
pub async fn serve_stdio(self) -> Result<()>
Serve the protocol on stdin/stdout until stdin closes or shutdown arrives.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Plugin
impl !UnwindSafe for Plugin
impl Forget for Plugin
impl Freeze for Plugin
impl Move for Plugin
impl Send for Plugin
impl Sync for Plugin
impl Unpin for Plugin
impl UnsafeUnpin for Plugin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more