pub struct Output { /* private fields */ }Expand description
The output channels for one command run.
Cloning is cheap: clones share the same writers.
Implementations§
Source§impl Output
impl Output
Sourcepub fn stdio() -> Self
pub fn stdio() -> Self
Output bound to the process stdout and stderr, with progress indicators enabled (they still hide themselves when stderr is not a TTY).
Sourcepub fn capture() -> (Self, Captured)
pub fn capture() -> (Self, Captured)
Output bound to in-memory buffers, with progress indicators disabled.
Returns the output and a handle that reads what was written.
Sourcepub fn capture_merged() -> (Self, Captured)
pub fn capture_merged() -> (Self, Captured)
Output whose two channels write to one in-memory buffer, in the order of the writes, with progress indicators disabled.
The TUI uses it: its output pane shows data and diagnostics as one
stream, as a terminal does. Captured::out returns the whole
stream and Captured::err returns the same text.
Captured::data returns only what went to the data channel.
Sourcepub fn teed(&self, limit: usize) -> (Self, Captured)
pub fn teed(&self, limit: usize) -> (Self, Captured)
Output that still writes to this output’s writers and also keeps a
copy of the text, as Output::capture_merged does.
The TUI uses it for a command that runs outside it: the user sees
the text live on the terminal, and the TUI shows the copy in its
scrollback after it returns. Progress indicators stay as they are
here (they draw on the real terminal and are not copied). The copy
keeps at most about limit bytes, the end of the text; whole lines
are dropped from its start. Captured::trimmed says when that
happened.
The result is a TUI output (Output::is_tui): its hints are read
in the TUI scrollback.
Sourcepub fn progress_enabled(&self) -> bool
pub fn progress_enabled(&self) -> bool
True when animated progress indicators may draw on the terminal.
Sourcepub fn is_tui(&self) -> bool
pub fn is_tui(&self) -> bool
True when this output belongs to the TUI. Error text then gives TUI next steps, not CLI flags.
Sourcepub fn progress_hook(&self) -> Option<ProgressHook>
pub fn progress_hook(&self) -> Option<ProgressHook>
The progress record of this run, when the output has one. The TUI’s output has one; the plain CLI output does not.
Sourcepub fn series_hook(&self) -> Option<SeriesHook>
pub fn series_hook(&self) -> Option<SeriesHook>
The series of a repeating run, when the output has one: the TUI’s pane output has one; the plain CLI output does not.
Sourcepub fn record_run(&self, metrics: &[Metric], record: RunRecord) -> bool
pub fn record_run(&self, metrics: &[Metric], record: RunRecord) -> bool
Hands one run to the screen’s series. Returns false when there is no series (the CLI), so the caller prints the run instead.
Sourcepub fn update_progress(&self, change: impl FnOnce(&mut RunProgress))
pub fn update_progress(&self, change: impl FnOnce(&mut RunProgress))
Changes the progress record. Does nothing when there is no hook.
Sourcepub fn note(&self, args: Arguments<'_>)
pub fn note(&self, args: Arguments<'_>)
Writes a status line to the diagnostic channel. Use
note!. A failed write is dropped: see the module
policy.
Sourcepub fn note_saved(&self, what: &str, path: impl Display)
pub fn note_saved(&self, what: &str, path: impl Display)
The one “saved to” line: <what> saved to: <where>, as a note.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Output
impl RefUnwindSafe for Output
impl Send for Output
impl Sync for Output
impl Unpin for Output
impl UnsafeUnpin for Output
impl UnwindSafe for Output
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
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> 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