pub struct ToolName(/* private fields */);Expand description
Strongly-typed tool name label.
ToolName identifies a tool by its canonical name (e.g., "shell", "web_scrape").
It is produced by the LLM in JSON tool-use responses and matched against the registered
tool registry at dispatch time.
§Label semantics (not a validated reference)
ToolName is an unvalidated label from untrusted input (LLM JSON). It does not
guarantee that a tool with this name is registered. Validation happens downstream at
tool dispatch, not at construction.
§Inner type: Arc<str>
The inner type is Arc<str>, not String. Tool names are cloned into multiple contexts
(event channels, tracing spans, tool output structs) during a single tool execution.
Arc<str> makes all clones O(1) vs O(n) for String. Use .clone() to duplicate
a ToolName — it is cheap.
§No Deref<Target=str>
ToolName does not implement Deref<Target=str>. This prevents the .to_owned()
footgun where muscle memory returns String instead of ToolName. Use .as_str() for
explicit string conversion and .clone() to duplicate the ToolName.
§Examples
use zeph_common::ToolName;
let name = ToolName::new("shell");
assert_eq!(name.as_str(), "shell");
assert_eq!(name, "shell");
// Clone is O(1) — Arc reference count increment only.
let name2 = name.clone();
assert_eq!(name, name2);Implementations§
Source§impl ToolName
impl ToolName
Sourcepub fn new(s: impl Into<Arc<str>>) -> Self
pub fn new(s: impl Into<Arc<str>>) -> Self
Construct a ToolName from any value convertible to Arc<str>.
This is the primary constructor. The name is accepted without validation — it is a label from the LLM wire or tool registry, not a proof of registration.
§Examples
use zeph_common::ToolName;
let name = ToolName::new("shell");
assert_eq!(name.as_str(), "shell");