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>>) -> ToolName
pub fn new(s: impl Into<Arc<str>>) -> ToolName
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");Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolName
impl<'de> Deserialize<'de> for ToolName
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolName, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolName, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ToolName
impl Serialize for ToolName
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,
impl Eq for ToolName
impl StructuralPartialEq for ToolName
Auto Trait Implementations§
impl Freeze for ToolName
impl RefUnwindSafe for ToolName
impl Send for ToolName
impl Sync for ToolName
impl Unpin for ToolName
impl UnsafeUnpin for ToolName
impl UnwindSafe for ToolName
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.