pub struct ToolRegistry { /* private fields */ }Expand description
Canonical tool registry — single source of truth.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
Sourcepub fn try_register(&self, entry: ToolEntry) -> bool
pub fn try_register(&self, entry: ToolEntry) -> bool
Register a tool from a NON-async context. Returns false if the lock was held and nothing was registered.
The Runtime::with_* builders are synchronous by convention (they take
and return Self, so they compose in a let rt = Runtime::new() .with_x().with_y(); chain), which leaves them unable to .await this
registry’s lock. They run during construction, before the runtime is
shared with anything, so the lock is uncontended and try_write
succeeds — the same reasoning Runtime::with_inference /
with_executor already rely on for try_write/try_lock. Async
callers should keep using Self::register.
Sourcepub async fn schemas(&self) -> Vec<ToolSchema>
pub async fn schemas(&self) -> Vec<ToolSchema>
Get all tool schemas (for model prompt generation).
Sourcepub async fn allowed_schemas(&self) -> Vec<ToolSchema>
pub async fn allowed_schemas(&self) -> Vec<ToolSchema>
Get schemas filtered by permission (e.g., only non-denied tools for model).
Sourcepub async fn by_source(&self, source_match: &ToolSource) -> Vec<ToolEntry>
pub async fn by_source(&self, source_match: &ToolSource) -> Vec<ToolEntry>
Get tools by source type.
Sourcepub async fn by_category(&self, category: &str) -> Vec<ToolEntry>
pub async fn by_category(&self, category: &str) -> Vec<ToolEntry>
Get tools by category.
Sourcepub async fn validate(&self) -> Vec<RegistryValidationError>
pub async fn validate(&self) -> Vec<RegistryValidationError>
Validate all entries — check for common issues.
Sourcepub async fn to_schema_map(&self) -> HashMap<String, ToolSchema>
pub async fn to_schema_map(&self) -> HashMap<String, ToolSchema>
Export the full HashMap of schemas (for backward compat with Runtime.tools).
pub async fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ToolRegistry
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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