pub enum ToolChunk {
Progress {
percent: f32,
message: String,
},
Partial {
data: Value,
index: usize,
},
Complete {
result: ToolResult,
},
Error {
tool: String,
message: String,
retryable: bool,
},
}Expand description
A chunk of streaming output from a tool.
§Security
- Progress updates are rate-limited by design (max 1/100ms recommended)
- Partial data is NOT hashed until Complete (prevents hash oracle attacks)
- Errors stop the stream immediately
Variants§
Progress
Progress update (percentage and message)
Partial
Partial data chunk (intermediate result)
Complete
Final complete result with cryptographic hash
Fields
§
result: ToolResultFinal result with Merkle-compatible hash
Error
Error during streaming (terminates stream) Note: Uses String to allow Clone/Serialize without ToolError constraints
Implementations§
Source§impl ToolChunk
impl ToolChunk
Sourcepub fn complete(result: ToolResult) -> Self
pub fn complete(result: ToolResult) -> Self
Create a complete chunk from a tool result
Sourcepub fn from_error(error: &ToolError) -> Self
pub fn from_error(error: &ToolError) -> Self
Create an error chunk from a ToolError
Sourcepub fn error(tool: impl Into<String>, message: impl Into<String>) -> Self
pub fn error(tool: impl Into<String>, message: impl Into<String>) -> Self
Create a simple error chunk
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if this chunk terminates the stream
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolChunk
impl<'de> Deserialize<'de> for ToolChunk
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ToolChunk
impl RefUnwindSafe for ToolChunk
impl Send for ToolChunk
impl Sync for ToolChunk
impl Unpin for ToolChunk
impl UnwindSafe for ToolChunk
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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