Struct term_transcript::Transcript
source · [−]pub struct Transcript<Out: TermOutput = Captured> { /* private fields */ }
Expand description
Transcript of a user interacting with the terminal.
Implementations
sourceimpl Transcript
impl Transcript
sourcepub fn from_inputs<Cmd: SpawnShell>(
options: &mut ShellOptions<Cmd>,
inputs: impl IntoIterator<Item = UserInput>
) -> Result<Self>
pub fn from_inputs<Cmd: SpawnShell>(
options: &mut ShellOptions<Cmd>,
inputs: impl IntoIterator<Item = UserInput>
) -> Result<Self>
Constructs a transcript from the sequence of given user input
s.
The inputs are executed in the shell specified in options
. A single shell is shared
among all commands.
Errors
- Returns an error if spawning the shell or any operations with it fail (such as reading stdout / stderr, or writing commands to stdin), or if the shell exits before all commands are executed.
sourcepub fn capture_output(
&mut self,
input: UserInput,
command: &mut Command
) -> Result<&mut Self>
pub fn capture_output(
&mut self,
input: UserInput,
command: &mut Command
) -> Result<&mut Self>
Captures stdout / stderr of the provided command
and adds it to Self::interactions()
.
The command
is spawned with closed stdin. This method blocks until the command exits.
The method succeeds regardless of the exit status of the command
.
Errors
- Returns an error if spawning the
command
or any operations with it fail (such as reading stdout / stderr).
sourceimpl Transcript<Parsed>
impl Transcript<Parsed>
sourcepub fn from_svg<R: BufRead>(reader: R) -> Result<Self, ParseError>
Available on crate feature test
only.
pub fn from_svg<R: BufRead>(reader: R) -> Result<Self, ParseError>
test
only.Parses a transcript from the provided reader
, which should point to an SVG XML tree
produced by Template::render()
(possibly within a larger document).
Errors
- Returns an error if the input cannot be parsed, usually because it was not produced
by
Template::render()
.
sourceimpl<Out: TermOutput> Transcript<Out>
impl<Out: TermOutput> Transcript<Out>
sourcepub fn interactions(&self) -> &[Interaction<Out>]
pub fn interactions(&self) -> &[Interaction<Out>]
Returns interactions in this transcript.
sourceimpl Transcript
impl Transcript
sourcepub fn add_interaction(
&mut self,
input: UserInput,
output: impl Into<String>
) -> &mut Self
pub fn add_interaction(
&mut self,
input: UserInput,
output: impl Into<String>
) -> &mut Self
Manually adds a new interaction to the end of this transcript.
This method allows capturing interactions that are difficult or impossible to capture
using more high-level methods: Self::from_inputs()
or Self::capture_output()
.
The resulting transcript will render just fine, but there could be issues
with testing it.
Trait Implementations
sourceimpl<Out: Clone + TermOutput> Clone for Transcript<Out>
impl<Out: Clone + TermOutput> Clone for Transcript<Out>
sourcefn clone(&self) -> Transcript<Out>
fn clone(&self) -> Transcript<Out>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<Out: Debug + TermOutput> Debug for Transcript<Out>
impl<Out: Debug + TermOutput> Debug for Transcript<Out>
sourceimpl<Out: TermOutput> Default for Transcript<Out>
impl<Out: TermOutput> Default for Transcript<Out>
Auto Trait Implementations
impl<Out> RefUnwindSafe for Transcript<Out> where
Out: RefUnwindSafe,
impl<Out> Send for Transcript<Out>
impl<Out> Sync for Transcript<Out>
impl<Out> Unpin for Transcript<Out> where
Out: Unpin,
impl<Out> UnwindSafe for Transcript<Out> where
Out: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more