pub struct ToolSpec { /* private fields */ }Expand description
Portable specification separated from tool executor behavior.
Implementations§
Source§impl ToolSpec
impl ToolSpec
Sourcepub fn new(
name: ToolName,
version: ToolVersion,
description: impl Into<String>,
input_schema: Value,
output_schema: Value,
effects: impl IntoIterator<Item = ToolEffect>,
execution: ToolExecutionSemantics,
) -> Result<Self, ToolSpecError>
pub fn new( name: ToolName, version: ToolVersion, description: impl Into<String>, input_schema: Value, output_schema: Value, effects: impl IntoIterator<Item = ToolEffect>, execution: ToolExecutionSemantics, ) -> Result<Self, ToolSpecError>
Creates a validated portable tool specification.
§Errors
Returns an error for invalid text, schemas, effects, or unsafe execution semantics.
Sourcepub fn with_source(self, source: ToolSource) -> Self
pub fn with_source(self, source: ToolSource) -> Self
Replaces the default native provenance with one validated frozen source.
Sourcepub fn with_label(self, label: impl Into<String>) -> Result<Self, ToolSpecError>
pub fn with_label(self, label: impl Into<String>) -> Result<Self, ToolSpecError>
Adds a bounded human-readable label kept out of model tool definitions.
§Errors
Returns an error for empty, oversized, or null-containing text.
Sourcepub fn with_prompt_hint(
self,
hint: impl Into<String>,
) -> Result<Self, ToolSpecError>
pub fn with_prompt_hint( self, hint: impl Into<String>, ) -> Result<Self, ToolSpecError>
Adds a bounded model prompt hint.
§Errors
Returns an error for empty, oversized, or null-containing text.
Sourcepub fn with_prompt_snippet(
self,
snippet: impl Into<String>,
) -> Result<Self, ToolSpecError>
pub fn with_prompt_snippet( self, snippet: impl Into<String>, ) -> Result<Self, ToolSpecError>
Adds one bounded model prompt snippet.
§Errors
Returns an error for empty, oversized, or null-containing text.
Sourcepub fn with_prompt_guidelines<I, S>(
self,
guidelines: I,
) -> Result<Self, ToolSpecError>
pub fn with_prompt_guidelines<I, S>( self, guidelines: I, ) -> Result<Self, ToolSpecError>
Adds bounded model prompt guidelines.
§Errors
Returns an error when a guideline is invalid or the collection exceeds its documented bounds.
Sourcepub fn with_ui_renderer(
self,
renderer: impl Into<String>,
) -> Result<Self, ToolSpecError>
pub fn with_ui_renderer( self, renderer: impl Into<String>, ) -> Result<Self, ToolSpecError>
Adds a bounded renderer selector with no UI implementation dependency.
§Errors
Returns an error when the selector is not canonical.
Sourcepub fn to_model_definition(&self) -> Result<ModelToolDefinition, ToolSpecError>
pub fn to_model_definition(&self) -> Result<ModelToolDefinition, ToolSpecError>
Projects this specification into the model-facing tool contract.
§Errors
Returns an error if model-layer bounds are stricter than this contract.
Sourcepub fn scheduler_class(&self) -> SchedulerClass
pub fn scheduler_class(&self) -> SchedulerClass
Derives conservative scheduler behavior from metadata only.
Sourcepub const fn version(&self) -> &ToolVersion
pub const fn version(&self) -> &ToolVersion
Returns the semantic contract version.
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Returns the model-visible description.
Sourcepub const fn input_schema(&self) -> &Value
pub const fn input_schema(&self) -> &Value
Returns the input object schema.
Sourcepub const fn output_schema(&self) -> &Value
pub const fn output_schema(&self) -> &Value
Returns the output object schema.
Sourcepub fn effects(&self) -> &[ToolEffect]
pub fn effects(&self) -> &[ToolEffect]
Returns sorted, deduplicated effects.
Sourcepub const fn source(&self) -> &ToolSource
pub const fn source(&self) -> &ToolSource
Returns frozen provider-neutral tool provenance.
Sourcepub const fn execution(&self) -> ToolExecutionSemantics
pub const fn execution(&self) -> ToolExecutionSemantics
Returns execution semantics.
Sourcepub fn prompt_hint(&self) -> Option<&str>
pub fn prompt_hint(&self) -> Option<&str>
Returns the optional model prompt hint.
Sourcepub fn prompt_snippet(&self) -> Option<&str>
pub fn prompt_snippet(&self) -> Option<&str>
Returns the optional model prompt snippet.
Sourcepub fn prompt_guidelines(&self) -> &[String]
pub fn prompt_guidelines(&self) -> &[String]
Returns bounded model prompt guidelines in declaration order.
Sourcepub fn ui_renderer(&self) -> Option<&str>
pub fn ui_renderer(&self) -> Option<&str>
Returns the optional UI renderer selector.