pub struct ToolServerHandle(/* private fields */);Expand description
A cheaply-cloneable handle to the shared tool server state.
All operations acquire locks directly on the underlying state. Multiple handles (e.g. across agents) can share the same state without channel-based message routing.
Implementations§
Source§impl ToolServerHandle
impl ToolServerHandle
Sourcepub async fn add_tool(
&self,
tool: impl ToolDyn + 'static,
) -> Result<(), ToolServerError>
pub async fn add_tool( &self, tool: impl ToolDyn + 'static, ) -> Result<(), ToolServerError>
Register a new static tool. Re-registering an existing name replaces the implementation (last wins) and keeps its position.
Sourcepub async fn append_toolset(
&self,
toolset: ToolSet,
) -> Result<(), ToolServerError>
pub async fn append_toolset( &self, toolset: ToolSet, ) -> Result<(), ToolServerError>
Merge an entire toolset into the server. Tool names from toolset
are appended to the static-tool list in toolset’s registration
order, so the tools become visible to the LLM via
Self::get_tool_defs. Existing names are replaced (last wins) and
keep their position.
Sourcepub async fn remove_tool(&self, tool_name: &str) -> Result<(), ToolServerError>
pub async fn remove_tool(&self, tool_name: &str) -> Result<(), ToolServerError>
Remove a tool by name from both the toolset and the static list.
Sourcepub async fn call_tool(
&self,
tool_name: &str,
args: &str,
) -> Result<String, ToolServerError>
pub async fn call_tool( &self, tool_name: &str, args: &str, ) -> Result<String, ToolServerError>
Look up and execute a tool by name.
The tool handle is cloned under a brief read lock so that long-running tool executions never block writers.
Sourcepub async fn get_tool_defs(
&self,
prompt: Option<String>,
) -> Result<Vec<ToolDefinition>, ToolServerError>
pub async fn get_tool_defs( &self, prompt: Option<String>, ) -> Result<Vec<ToolDefinition>, ToolServerError>
Retrieve tool definitions, optionally using a prompt to select dynamic tools from configured vector stores.
Trait Implementations§
Source§impl Clone for ToolServerHandle
impl Clone for ToolServerHandle
Source§fn clone(&self) -> ToolServerHandle
fn clone(&self) -> ToolServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolServerHandle
impl !UnwindSafe for ToolServerHandle
impl Freeze for ToolServerHandle
impl Send for ToolServerHandle
impl Sync for ToolServerHandle
impl Unpin for ToolServerHandle
impl UnsafeUnpin for ToolServerHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more