pub struct BackendRegistry { /* private fields */ }Expand description
Registry that maps tool names to their backends
When a backend is registered, the registry queries its supported_tools() and creates mappings for each tool. This allows for efficient lookup of the appropriate backend for a given tool name.
Implementations§
Source§impl BackendRegistry
impl BackendRegistry
Sourcepub async fn register(&mut self, name: String, backend: Arc<dyn ToolBackend>)
pub async fn register(&mut self, name: String, backend: Arc<dyn ToolBackend>)
Register a backend with the given name
This method queries the backend’s supported_tools() and creates mappings for each tool. If a tool is already mapped to another backend, it will be overwritten.
§Arguments
name- A unique name for this backend instancebackend- The backend implementation
Sourcepub fn get_backend_for_tool(
&self,
tool_name: &str,
) -> Option<&Arc<dyn ToolBackend>>
pub fn get_backend_for_tool( &self, tool_name: &str, ) -> Option<&Arc<dyn ToolBackend>>
Get the backend for a specific tool
Returns the backend that can handle the given tool name, or None if no backend supports that tool.
§Arguments
tool_name- The name of the tool to look up
Sourcepub fn backends(&self) -> &Vec<(String, Arc<dyn ToolBackend>)>
pub fn backends(&self) -> &Vec<(String, Arc<dyn ToolBackend>)>
Get all registered backends
Returns a vector of (name, backend) pairs for all registered backends.
Sourcepub fn tool_mappings(&self) -> &HashMap<String, Arc<dyn ToolBackend>>
pub fn tool_mappings(&self) -> &HashMap<String, Arc<dyn ToolBackend>>
Get all tool mappings
Returns a reference to the tool name -> backend mapping.
Sourcepub async fn supported_tools(&self) -> Vec<String>
pub async fn supported_tools(&self) -> Vec<String>
Check which tools are supported
Returns a vector of all tool names that have registered backends.
Sourcepub fn unregister(&mut self, name: &str) -> bool
pub fn unregister(&mut self, name: &str) -> bool
Remove a backend by name
This removes the backend and all its tool mappings. Returns true if a backend was removed, false if the name wasn’t found.
Sourcepub async fn get_tool_schemas(&self) -> Vec<ToolSchema>
pub async fn get_tool_schemas(&self) -> Vec<ToolSchema>
Get API tools from all registered backends
Collects and returns all API tool descriptions from all registered backends. This provides a unified view of all available tools across all backends.
Trait Implementations§
Source§impl BackendResolver for BackendRegistry
impl BackendResolver for BackendRegistry
fn resolve<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Arc<dyn ToolBackend>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tool_schemas<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ToolSchema>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn requires_approval(&self, _tool_name: &str) -> Option<bool>
Auto Trait Implementations§
impl Freeze for BackendRegistry
impl !RefUnwindSafe for BackendRegistry
impl Send for BackendRegistry
impl Sync for BackendRegistry
impl Unpin for BackendRegistry
impl !UnwindSafe for BackendRegistry
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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request