pub struct Output<'a> { /* private fields */ }
Expand description
A terminal Connection
’s output.
Since terminal output is buffered, actually executing commands requires
flushing the output. As a convenience, Output::print
and
Output::println
write strings and Output::exec
writes individual
commands, while also flushing the output on every invocation.
Implementations§
Source§impl Output<'_>
impl Output<'_>
Sourcepub fn println<T: AsRef<str>>(&mut self, text: T) -> Result<()>
pub fn println<T: AsRef<str>>(&mut self, text: T) -> Result<()>
Write and flush the text followed by carriage return and line feed.
Sourcepub fn exec<C: Command>(&mut self, cmd: C) -> Result<()>
pub fn exec<C: Command>(&mut self, cmd: C) -> Result<()>
Execute the command.
This method writes the display for the given command and then flushes the terminal output.
Sourcepub fn exec_defer<C1, C2>(&mut self, cmd1: C1, cmd2: C2) -> Result<()>
pub fn exec_defer<C1, C2>(&mut self, cmd1: C1, cmd2: C2) -> Result<()>
Execute one command and defer the other.
This method tries to write the first command to the terminal’s output. If that succeeds, it enqueues the second command for execution when the connection is being closed and then flushes the output.
The second command must be 'static
, so that it is alive for the
lifetime of the connection. It must be Send
, so that connection
objects can be moved across threads. Since most commands are zero-sized
types, they trivially fulfill both requirements.
Trait Implementations§
Source§impl Write for Output<'_>
impl Write for Output<'_>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)