pub struct ToolProxy { /* private fields */ }Expand description
Holds tool registrations + the ledger + the secret. Send + Sync via
inner Mutex; cheap to clone().
Implementations§
Source§impl ToolProxy
impl ToolProxy
Sourcepub fn new(ledger: Ledger) -> Self
pub fn new(ledger: Ledger) -> Self
Construct a proxy backed by the given (probably empty) ledger.
Sourcepub fn register(&self, id: impl Into<String>, handler: Arc<dyn ToolHandler>)
pub fn register(&self, id: impl Into<String>, handler: Arc<dyn ToolHandler>)
Register a tool under id. Subsequent registrations under the same
id overwrite (last wins).
Sourcepub fn invoke(&self, id: &str, args: &Value) -> Result<Value>
pub fn invoke(&self, id: &str, args: &Value) -> Result<Value>
Invoke a registered tool. The call is recorded in the ledger before being returned to the caller.
Sourcepub fn ledger_snapshot(&self) -> Ledger
pub fn ledger_snapshot(&self) -> Ledger
Snapshot the current ledger (clones it so the caller can serialize without holding the lock).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolProxy
impl RefUnwindSafe for ToolProxy
impl Send for ToolProxy
impl Sync for ToolProxy
impl Unpin for ToolProxy
impl UnsafeUnpin for ToolProxy
impl UnwindSafe for ToolProxy
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