pub struct ToolCallView<'a> {
pub call: &'a ToolCall,
pub result: Option<&'a ToolResult>,
pub state: CallState,
pub theme: Theme,
pub facts: Option<&'a ToolResultContext>,
pub took: Option<Duration>,
pub output: Option<&'a str>,
pub children: &'a [ChildCall],
}Expand description
A tool call and its result, if it has one yet, as a renderer sees them.
Fields§
§call: &'a ToolCallThe call. While it streams, its arguments are what has come of them, and its id is not the final one.
result: Option<&'a ToolResult>Its result, once it is in the conversation.
state: CallStateWhere the call stands.
theme: ThemeThe transcript’s colors.
facts: Option<&'a ToolResultContext>What the call published, such as rig-core’s ExitStatus and
FilesChanged, once it settled: in this run, or in an earlier one
of a resumed session whose effect log was kept.
took: Option<Duration>How long it ran, once it settled, as for facts.
output: Option<&'a str>The output so far of a running call whose tool reports it as it
runs (CallOutput), such as a command’s: cut as tool output is
cut, its last lines after a line that counts the earlier ones.
None once the call answered, and before it printed anything.
children: &'a [ChildCall]The tool and model calls the call started, and those they started,
in order, each after the one that started it, through any effect
between that is no call: such as a subagent’s calls under the call
that spawned it, through the spawn and the brief it was sent. Also
after a resume, from the session’s effect log
(PastEffects).
Implementations§
Source§impl<'a> ToolCallView<'a>
impl<'a> ToolCallView<'a>
Sourcepub fn new(
call: &'a ToolCall,
result: Option<&'a ToolResult>,
state: CallState,
) -> Self
pub fn new( call: &'a ToolCall, result: Option<&'a ToolResult>, state: CallState, ) -> Self
call, answered by result if it was, standing as state, with
no facts or output known, in the default colors.
Sourcepub fn argument(&self, key: &str) -> Option<&str>
pub fn argument(&self, key: &str) -> Option<&str>
The string argument key, if the call has one.
Sourcepub fn result_text(&self) -> Option<String>
pub fn result_text(&self) -> Option<String>
The result’s text, joined, if the tool answered.
Sourcepub fn failed(&self) -> bool
pub fn failed(&self) -> bool
Whether the call failed: the tool answered with an error, or the
process it ran did not exit with 0 (ExitStatus).
Sourcepub fn header(
&self,
title: impl Into<String>,
detail: impl Into<String>,
) -> Line<'static>
pub fn header( &self, title: impl Into<String>, detail: impl Into<String>, ) -> Line<'static>
The header line: title in bold and detail dimmed on a band
tinted by where the call stands (Theme’s call_* colors), with
the state in words too when it is running, held or failed (how its
process ended, when it ran one).
Sourcepub fn header_spans(
&self,
title: impl Into<String>,
detail: Vec<Span<'static>>,
) -> Line<'static>
pub fn header_spans( &self, title: impl Into<String>, detail: Vec<Span<'static>>, ) -> Line<'static>
header with detail in spans styled by the look,
such as a highlighted command; the state’s words still end it.
Sourcepub fn result_lines(&self) -> Vec<Line<'static>>
pub fn result_lines(&self) -> Vec<Line<'static>>
The whole result, indented under the header, red for an error. A unified diff is
coloured. The line that says the tool cut its output
(OutputCut), naming the file with all of it, is on its side.
Before the result, a running call’s progress.
Sourcepub fn progress_lines(&self) -> Vec<Line<'static>>
pub fn progress_lines(&self) -> Vec<Line<'static>>
A running call’s progress, indented under the header, where its result goes once it answers; none without one.
Sourcepub fn default_lines(&self) -> Vec<Line<'static>>
pub fn default_lines(&self) -> Vec<Line<'static>>
The look of a tool with no renderer: the name, the arguments and the result.
Auto Trait Implementations§
impl<'a> Freeze for ToolCallView<'a>
impl<'a> RefUnwindSafe for ToolCallView<'a>
impl<'a> Send for ToolCallView<'a>
impl<'a> Sync for ToolCallView<'a>
impl<'a> Unpin for ToolCallView<'a>
impl<'a> UnsafeUnpin for ToolCallView<'a>
impl<'a> UnwindSafe for ToolCallView<'a>
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<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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