Struct PolicyTool
pub struct PolicyTool { /* private fields */ }Expand description
A ToolFunction decorator that enforces a ToolPolicy.
Implementations§
§impl PolicyTool
impl PolicyTool
pub fn new(inner: Arc<dyn ToolFunction>, policy: ToolPolicy) -> PolicyTool
pub fn new(inner: Arc<dyn ToolFunction>, policy: ToolPolicy) -> PolicyTool
Wrap inner with the given policy.
pub fn wrap(
inner: Arc<dyn ToolFunction>,
policy: ToolPolicy,
) -> Arc<dyn ToolFunction>
pub fn wrap( inner: Arc<dyn ToolFunction>, policy: ToolPolicy, ) -> Arc<dyn ToolFunction>
Wrap inner only if the policy enforces something; otherwise return inner.
pub fn requires_confirmation(&self) -> bool
pub fn requires_confirmation(&self) -> bool
Whether this tool requires user confirmation before execution.
pub fn policy(&self) -> &ToolPolicy
pub fn policy(&self) -> &ToolPolicy
The policy attached to this tool.
Trait Implementations§
§impl ToolFunction for PolicyTool
impl ToolFunction for PolicyTool
§fn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what this tool does.
§fn parameters(&self) -> Option<Value>
fn parameters(&self) -> Option<Value>
JSON Schema for the tool’s input parameters, or
None if parameterless.§fn requires_confirmation(&self) -> bool
fn requires_confirmation(&self) -> bool
Whether this tool must be confirmed before it runs. Defaults to
false. Read more§fn confirmation_message(&self) -> Option<&str>
fn confirmation_message(&self) -> Option<&str>
Optional hint shown when confirmation is requested.
Auto Trait Implementations§
impl Freeze for PolicyTool
impl !RefUnwindSafe for PolicyTool
impl Send for PolicyTool
impl Sync for PolicyTool
impl Unpin for PolicyTool
impl !UnwindSafe for PolicyTool
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