pub struct ToolCallAssembler { /* private fields */ }Expand description
Accumulates streamed tool-call fragments by content-block index.
Implementations§
Source§impl ToolCallAssembler
impl ToolCallAssembler
Sourcepub fn begin(
&mut self,
index: usize,
id: impl Into<String>,
name: impl Into<String>,
)
pub fn begin( &mut self, index: usize, id: impl Into<String>, name: impl Into<String>, )
Begin a tool call at index (from the stream’s content_block_start).
Sourcepub fn push_json(
&mut self,
index: usize,
fragment: &str,
) -> Result<(), AssembleError>
pub fn push_json( &mut self, index: usize, fragment: &str, ) -> Result<(), AssembleError>
Append a raw partial-JSON fragment for index. Never parsed here.
§Errors
AssembleError::MissingStart if no ToolCallAssembler::begin was seen for
index.
Sourcepub fn finish(self) -> Result<Vec<ContentBlock>, AssembleError>
pub fn finish(self) -> Result<Vec<ContentBlock>, AssembleError>
Finish: parse each accumulated buffer once, in index order, into
ContentBlock::ToolUse blocks.
An empty/whitespace buffer becomes {} — Anthropic sends empty input for a
no-argument tool call.
§Errors
AssembleError::InvalidJson if any accumulated buffer is not valid JSON.
Trait Implementations§
Source§impl Debug for ToolCallAssembler
impl Debug for ToolCallAssembler
Source§impl Default for ToolCallAssembler
impl Default for ToolCallAssembler
Source§fn default() -> ToolCallAssembler
fn default() -> ToolCallAssembler
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ToolCallAssembler
impl RefUnwindSafe for ToolCallAssembler
impl Send for ToolCallAssembler
impl Sync for ToolCallAssembler
impl Unpin for ToolCallAssembler
impl UnsafeUnpin for ToolCallAssembler
impl UnwindSafe for ToolCallAssembler
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