pub struct ToolSchema {
pub properties: HashMap<String, PropertySchema>,
pub required: Vec<String>,
}Expand description
Tool input schema with typed property definitions.
Represents a JSON Schema { type: "object", properties: {...}, required: [...] }.
Uses PropertySchema for type-safe parameter definitions.
Fields§
§properties: HashMap<String, PropertySchema>Parameter definitions keyed by parameter name.
required: Vec<String>List of required parameter names.
Implementations§
Source§impl ToolSchema
impl ToolSchema
Sourcepub fn new() -> ToolSchema
pub fn new() -> ToolSchema
Create an empty schema.
Sourcepub fn from_json(schema: &Value) -> ToolSchema
pub fn from_json(schema: &Value) -> ToolSchema
Create from a JSON Schema value (for backward compatibility).
Sourcepub fn add_enum_param(&mut self, name: &str, values: &[&str], description: &str)
pub fn add_enum_param(&mut self, name: &str, values: &[&str], description: &str)
Add a string parameter with enum values.
Sourcepub fn set_enum(&mut self, param: &str, values: &[String])
pub fn set_enum(&mut self, param: &str, values: &[String])
Set enum values on an existing parameter.
Sourcepub fn add_property(&mut self, name: &str, prop: PropertySchema)
pub fn add_property(&mut self, name: &str, prop: PropertySchema)
Add a typed property.
Sourcepub fn add_param(&mut self, name: &str, schema: Value)
pub fn add_param(&mut self, name: &str, schema: Value)
Add a parameter with a raw JSON Schema value (backward compat).
Sourcepub fn remove_params(&mut self, names: &[&str])
pub fn remove_params(&mut self, names: &[&str])
Remove parameters not supported by the current provider.
Sourcepub fn set_required(&mut self, param: &str, required: bool)
pub fn set_required(&mut self, param: &str, required: bool)
Set whether a parameter is required.
Sourcepub fn set_description(&mut self, param: &str, desc: &str)
pub fn set_description(&mut self, param: &str, desc: &str)
Update a parameter’s description.
Sourcepub fn set_default(&mut self, param: &str, value: Value)
pub fn set_default(&mut self, param: &str, value: Value)
Set a default value for a parameter.
Trait Implementations§
Source§impl Clone for ToolSchema
impl Clone for ToolSchema
Source§fn clone(&self) -> ToolSchema
fn clone(&self) -> ToolSchema
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolSchema
impl Debug for ToolSchema
Source§impl Default for ToolSchema
impl Default for ToolSchema
Source§fn default() -> ToolSchema
fn default() -> ToolSchema
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ToolSchema
impl<'de> Deserialize<'de> for ToolSchema
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ToolSchema
impl Serialize for ToolSchema
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ToolSchema
impl RefUnwindSafe for ToolSchema
impl Send for ToolSchema
impl Sync for ToolSchema
impl Unpin for ToolSchema
impl UnsafeUnpin for ToolSchema
impl UnwindSafe for ToolSchema
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