pub struct ToolBinding {
pub tool_name: String,
pub action: String,
pub resource: String,
pub resource_arg: Option<String>,
pub required_args: Vec<String>,
/* private fields */
}Expand description
Declares how one tool maps onto the Typesec (action, resource) plane.
Fields§
§tool_name: StringTool name as exposed to the model.
action: StringTypesec action (permission name) required to run the tool.
resource: StringResource the action applies to when no argument supplies one.
resource_arg: Option<String>Name of a string tool argument that carries the resource id.
When set, the resource is taken from the call’s arguments and the call is denied if the argument is missing or not a string — a binding that promises per-argument resources must not silently widen.
required_args: Vec<String>Arguments that must be present on every call (any JSON type).
Implementations§
Source§impl ToolBinding
impl ToolBinding
Sourcepub fn new(
tool_name: impl Into<String>,
action: impl Into<String>,
resource: impl Into<String>,
) -> Self
pub fn new( tool_name: impl Into<String>, action: impl Into<String>, resource: impl Into<String>, ) -> Self
Bind a tool to a fixed action and resource.
Sourcepub fn resource_from_arg(self, arg: impl Into<String>) -> Self
pub fn resource_from_arg(self, arg: impl Into<String>) -> Self
Take the resource id from the named string argument of each call.
Sourcepub fn require_args<I, S>(self, args: I) -> Self
pub fn require_args<I, S>(self, args: I) -> Self
Require the named arguments to be present on every call.
Sourcepub fn arg_glob(
self,
arg: impl Into<String>,
pattern: &str,
) -> Result<Self, InteropError>
pub fn arg_glob( self, arg: impl Into<String>, pattern: &str, ) -> Result<Self, InteropError>
Constrain the named string argument to a glob pattern (compiled once, here). The argument becomes required. Fails on an invalid pattern.
Sourcepub fn args_schema(self, schema: Value) -> Result<Self, InteropError>
pub fn args_schema(self, schema: Value) -> Result<Self, InteropError>
Validate the whole arguments object against a JSON Schema (compiled once, here). Malformed or out-of-range arguments are denied before any policy evaluation. Fails on an invalid schema.
Trait Implementations§
Source§impl Clone for ToolBinding
impl Clone for ToolBinding
Source§fn clone(&self) -> ToolBinding
fn clone(&self) -> ToolBinding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more