pub trait ToolEnum: Sized + Copy {
// Required methods
fn type_name() -> &'static str;
fn from_i32(v: i32) -> Option<Self>;
fn from_str(s: &str) -> Option<Self>;
fn as_i32(self) -> i32;
fn all_int_values() -> Vec<i32>;
fn all_string_values() -> Vec<&'static str>;
}Expand description
v1.4.84 §5 B2: 统一 MCP tool enum 接口,让 deser_int_or_enum_str 可泛型化。
Required Methods§
Sourcefn from_str(s: &str) -> Option<Self>
fn from_str(s: &str) -> Option<Self>
按 string 名 / 别名查 enum variant;未定义 → None
实装应 trim + 大小写灵活匹配(canonical 名 + 常见 alias)
Sourcefn all_int_values() -> Vec<i32>
fn all_int_values() -> Vec<i32>
列举所有合法 int 值(用于 error message)
Sourcefn all_string_values() -> Vec<&'static str>
fn all_string_values() -> Vec<&'static str>
列举所有 canonical string 名(用于 error message / schema hints)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.