Skip to main content

ToolDefExtensionBuilder

Struct ToolDefExtensionBuilder 

Source
pub struct ToolDefExtensionBuilder { /* private fields */ }
Expand description

Builder for ToolDefExtension.

Implementations§

Source§

impl ToolDefExtensionBuilder

Source

pub fn tool(self, tool: ToolImpl) -> Self

Register a ToolImpl (definition + exec functions).

Source

pub fn tool_fn( self, def: ToolDef, exec: impl Fn(&ToolArgs) -> Result<String, String> + Send + Sync + 'static, ) -> Self

Register a tool with its definition and synchronous exec function.

Source

pub fn tool_with_dry_run( self, def: ToolDef, exec: impl Fn(&ToolArgs) -> Result<String, String> + Send + Sync + 'static, dry_run: impl Fn(&ToolArgs) -> Result<String, String> + Send + Sync + 'static, ) -> Self

Register a sync tool plus a custom --dry-run handler.

Source

pub fn async_tool_fn<F, Fut>(self, def: ToolDef, exec: F) -> Self
where F: Fn(ToolArgs) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<String, String>> + Send + 'static,

Register a tool with its definition and async exec function.

Source

pub fn sanitize_errors(self, sanitize: bool) -> Self

Replace callback errors with generic messages before exposing them to scripts.

Source

pub fn build(&self) -> ToolDefExtension

Build the extension.

Each call mints a fresh, isolated invocation log. Clones of the returned extension also get a fresh log so cloned configuration can be reused across tenants without sharing traces. Use ToolDefExtension::invocation_trace before registration when a caller intentionally wants a handle for this extension’s trace.

Trait Implementations§

Source§

impl Default for ToolDefExtensionBuilder

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