pub struct CollectionBuilder<M = NoMeta> { /* private fields */ }Expand description
Builder for ToolCollection with support for shared context
injection. Construct via ToolCollection::builder().
ⓘ
let ctx = Arc::new(MyState::new());
let tools = ToolCollection::<Policy>::builder()
.with_context(ctx)
.collect()?;Implementations§
Source§impl<M> CollectionBuilder<M>
impl<M> CollectionBuilder<M>
Sourcepub fn with_context<T>(self, ctx: Arc<T>) -> CollectionBuilder<M>
pub fn with_context<T>(self, ctx: Arc<T>) -> CollectionBuilder<M>
Attach a shared context that will be injected into every tool whose
first parameter is named ctx. The context type T must match what
the tools expect — a mismatch is caught at collect()
time with a clear error.
Source§impl<M> CollectionBuilder<M>where
M: DeserializeOwned,
impl<M> CollectionBuilder<M>where
M: DeserializeOwned,
Sourcepub fn collect(self) -> Result<ToolCollection<M>, ToolError>
pub fn collect(self) -> Result<ToolCollection<M>, ToolError>
Build the collection from the global tool inventory. Validates:
- Every tool’s
meta_jsondeserializes intoM. - Every
needs_ctxtool’s expectedTypeIdmatches the builder’s. - No
needs_ctxtool exists when no context was provided.
Auto Trait Implementations§
impl<M> Freeze for CollectionBuilder<M>
impl<M = NoMeta> !RefUnwindSafe for CollectionBuilder<M>
impl<M> Send for CollectionBuilder<M>where
M: Send,
impl<M> Sync for CollectionBuilder<M>where
M: Sync,
impl<M> Unpin for CollectionBuilder<M>where
M: Unpin,
impl<M> UnsafeUnpin for CollectionBuilder<M>
impl<M = NoMeta> !UnwindSafe for CollectionBuilder<M>
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
Mutably borrows from an owned value. Read more