pub struct ToolResult { /* private fields */ }Expand description
The single structured execution view used by dispatch, hooks, and telemetry.
Each result has exactly one disposition. The tagged state is private so tool
authors keep returning ordinary Result values while runtime callers use
the stable query methods on this type.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn success(output: ToolOutput) -> Self
pub fn success(output: ToolOutput) -> Self
Creates a successful canonical tool result.
Sourcepub fn failed(error: ToolExecutionError) -> Self
pub fn failed(error: ToolExecutionError) -> Self
Creates a failed or refused canonical tool result.
Sourcepub fn skipped(reason: impl Into<String>) -> Self
pub fn skipped(reason: impl Into<String>) -> Self
Creates a result for a call skipped by runtime policy.
Sourcepub fn output(&self) -> &ToolOutput
pub fn output(&self) -> &ToolOutput
Canonical model-visible output before any presentation-only hook rewrite.
Sourcepub fn error(&self) -> Option<&ToolExecutionError>
pub fn error(&self) -> Option<&ToolExecutionError>
Structured execution error, if execution failed.
Intentional refusals are available through Self::refusal instead.
Sourcepub fn refusal(&self) -> Option<&ToolExecutionError>
pub fn refusal(&self) -> Option<&ToolExecutionError>
Structured refusal details, if the tool intentionally declined the call.
This is mutually exclusive with Self::error.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Whether the tool completed successfully.
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Whether execution failed.
An intentional refusal is not an execution error; inspect
Self::is_refused instead.
Sourcepub fn is_skipped(&self) -> bool
pub fn is_skipped(&self) -> bool
Whether the framework skipped execution before the tool body ran.
Sourcepub fn is_refused(&self) -> bool
pub fn is_refused(&self) -> bool
Whether a tool refused execution.
Sourcepub fn is_error_kind(&self, kind: ToolErrorKind) -> bool
pub fn is_error_kind(&self, kind: ToolErrorKind) -> bool
Whether this is an error of exactly kind.
A refusal does not match, even though its envelope uses the normalized
ToolErrorKind::PermissionDenied kind.
Sourcepub fn status_name(&self) -> &'static str
pub fn status_name(&self) -> &'static str
Returns the stable telemetry name for this result disposition.
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ToolResult
impl !UnwindSafe for ToolResult
impl Freeze for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnsafeUnpin for ToolResult
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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