Skip to main content

CollectionBuilder

Struct CollectionBuilder 

Source
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>

Source

pub fn with_context<T>(self, ctx: Arc<T>) -> CollectionBuilder<M>
where T: Send + Sync + 'static,

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>

Source

pub fn collect(self) -> Result<ToolCollection<M>, ToolError>

Build the collection from the global tool inventory. Validates:

  • Every tool’s meta_json deserializes into M.
  • Every needs_ctx tool’s expected TypeId matches the builder’s.
  • No needs_ctx tool 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<M> MetaArg<M> for M

Source§

fn into_meta(self) -> M

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.