Struct ToolPolicy
pub struct ToolPolicy {
pub timeout: Option<Duration>,
pub cache: bool,
pub confirm: bool,
pub confirm_message: Option<String>,
}Expand description
Optional per-tool execution policy.
Fields§
§timeout: Option<Duration>If set, the tool call is bounded by this duration.
cache: boolIf true, successful results are memoized by (name, canonical args).
confirm: boolIf true, the tool requires user confirmation before execution.
confirm_message: Option<String>Optional hint shown when confirmation is requested.
Implementations§
§impl ToolPolicy
impl ToolPolicy
pub fn new() -> ToolPolicy
pub fn new() -> ToolPolicy
Create an empty policy (no enforcement).
pub fn is_noop(&self) -> bool
pub fn is_noop(&self) -> bool
Whether this policy enforces anything at all.
Used to decide whether wrapping a tool in a PolicyTool is worthwhile.
pub fn with_timeout(self, d: Duration) -> ToolPolicy
pub fn with_timeout(self, d: Duration) -> ToolPolicy
Set a timeout.
pub fn with_cache(self) -> ToolPolicy
pub fn with_cache(self) -> ToolPolicy
Enable caching.
pub fn with_confirm(self, message: Option<String>) -> ToolPolicy
pub fn with_confirm(self, message: Option<String>) -> ToolPolicy
Require confirmation with an optional message.
pub fn merge(self, other: &ToolPolicy) -> ToolPolicy
pub fn merge(self, other: &ToolPolicy) -> ToolPolicy
Merge another policy into this one (the other takes precedence where set).
Trait Implementations§
§impl Clone for ToolPolicy
impl Clone for ToolPolicy
§fn clone(&self) -> ToolPolicy
fn clone(&self) -> ToolPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for ToolPolicy
impl Debug for ToolPolicy
§impl Default for ToolPolicy
impl Default for ToolPolicy
§fn default() -> ToolPolicy
fn default() -> ToolPolicy
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ToolPolicy
impl RefUnwindSafe for ToolPolicy
impl Send for ToolPolicy
impl Sync for ToolPolicy
impl Unpin for ToolPolicy
impl UnwindSafe for ToolPolicy
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