#[non_exhaustive]pub struct ToolRouter<S> {
pub map: HashMap<Cow<'static, str>, ToolRoute<S>>,
pub transparent_when_not_found: bool,
/* private fields */
}server only.Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.map: HashMap<Cow<'static, str>, ToolRoute<S>>§transparent_when_not_found: boolImplementations§
Source§impl<S> ToolRouter<S>where
S: MaybeSend + 'static,
impl<S> ToolRouter<S>where
S: MaybeSend + 'static,
pub fn new() -> Self
pub fn with_route<R, A>(self, route: R) -> Selfwhere
R: IntoToolRoute<S, A>,
Sourcepub fn with_sync_tool<T>(self) -> Selfwhere
T: SyncTool<S> + 'static,
pub fn with_sync_tool<T>(self) -> Selfwhere
T: SyncTool<S> + 'static,
Add a tool that implements SyncTool
Sourcepub fn with_async_tool<T>(self) -> Selfwhere
T: AsyncTool<S> + 'static,
pub fn with_async_tool<T>(self) -> Selfwhere
T: AsyncTool<S> + 'static,
Add a tool that implements AsyncTool
pub fn add_route(&mut self, item: ToolRoute<S>)
pub fn merge(&mut self, other: ToolRouter<S>)
Sourcepub fn remove_route(&mut self, name: &str)
pub fn remove_route(&mut self, name: &str)
Remove a tool route from the router.
The disabled state is preserved: if the name was in the disabled
set, it stays there so that a future add_route
or merge with the same name will inherit the
disabled state. To also clear the disabled marker, call
enable_route afterwards.
Sourcepub fn has_route(&self, name: &str) -> bool
pub fn has_route(&self, name: &str) -> bool
Returns true if the tool is registered and not currently
disabled.
Sourcepub fn disable_route(&mut self, name: impl Into<Cow<'static, str>>) -> bool
pub fn disable_route(&mut self, name: impl Into<Cow<'static, str>>) -> bool
Disable a tool by name. Hidden from list_all, get, rejected by
call. Re-enable with enable_route.
Returns true if the name was newly added to the disabled set.
The name is recorded even if no matching route exists yet, so routes
added later will inherit the disabled state.
Sourcepub fn enable_route(&mut self, name: &str) -> bool
pub fn enable_route(&mut self, name: &str) -> bool
Re-enable a previously disabled tool. Returns true if the name
was in the disabled set.
Sourcepub fn is_disabled(&self, name: &str) -> bool
pub fn is_disabled(&self, name: &str) -> bool
Returns true if the tool exists in the router and is currently
disabled. Returns false if the tool does not exist or if the name
was pre-disabled without a matching route.
Sourcepub fn with_disabled(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_disabled(self, name: impl Into<Cow<'static, str>>) -> Self
Builder-style variant of disable_route.
The name is recorded even if no matching route has been added yet,
so it can be called before with_route in a
builder chain.
Sourcepub fn set_notifier(&mut self, f: impl Fn() + Send + Sync + 'static)
pub fn set_notifier(&mut self, f: impl Fn() + Send + Sync + 'static)
Install a callback invoked when the visible tool list changes.
pub fn clear_notifier(&mut self)
Sourcepub fn bind_peer_notifier(&mut self, peer: &Peer<RoleServer>)
pub fn bind_peer_notifier(&mut self, peer: &Peer<RoleServer>)
Install a notifier that sends notifications/tools/list_changed
via the given peer.
pub async fn call( &self, context: ToolCallContext<'_, S>, ) -> Result<CallToolResponse, ErrorData>
pub fn list_all(&self) -> Vec<Tool>
Trait Implementations§
Source§impl<S> Add for ToolRouter<S>where
S: MaybeSend + 'static,
impl<S> Add for ToolRouter<S>where
S: MaybeSend + 'static,
Source§type Output = ToolRouter<S>
type Output = ToolRouter<S>
+ operator.Source§impl<S> AddAssign for ToolRouter<S>where
S: MaybeSend + 'static,
impl<S> AddAssign for ToolRouter<S>where
S: MaybeSend + 'static,
Source§fn add_assign(&mut self, other: ToolRouter<S>)
fn add_assign(&mut self, other: ToolRouter<S>)
+= operation. Read more