Skip to main content

ToolBatch

Struct ToolBatch 

Source
pub struct ToolBatch { /* private fields */ }
Expand description

One tool batch with a completed prefix and pending suffix.

Implementations§

Source§

impl ToolBatch

Source

pub fn new(calls: Vec<ToolCallContext>) -> Result<Self, BatchError>

Creates a batch from declarations in their original order.

Source

pub fn calls(&self) -> &[ToolCallEntry]

Returns the pending suffix.

Source

pub fn calls_mut(&mut self) -> &mut [ToolCallEntry]

Mutably returns the pending suffix.

Source

pub fn results(&self) -> &[ToolCallEntry]

Returns the completed prefix.

Source

pub fn results_mut(&mut self) -> &mut [ToolCallEntry]

Mutably returns the completed prefix for output editing and ordering.

Source

pub fn completed_len(&self) -> usize

Returns the number of completed entries.

Source

pub fn declaration_ids(&self) -> Vec<BlockId>

Returns declaration identities in the batch’s current entry order.

Source

pub fn validate(&self) -> Result<(), BatchError>

Validates the completed-prefix/pending-suffix and identity invariants.

Source

pub fn resolve_at( &mut self, index: usize, result_block_id: BlockId, result: ToolResultPayload, ) -> Result<(), RejectedToolResult>

Installs a result at an absolute entry index and advances the prefix. A refused result leaves the batch unchanged and is handed back with the reason, so a caller can retry or report it without a copy.

Source

pub fn validate_complete(&self) -> Result<(), BatchError>

Validates the invariants and that every entry has a result.

Source

pub fn into_results( self, ) -> Result<Vec<(BlockId, ToolResultPayload)>, (BatchError, Self)>

Consumes a fully completed batch into result blocks in current order.

Trait Implementations§

Source§

impl Debug for ToolBatch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.