pub struct TabWriter<W> { /* private fields */ }Expand description
TabWriter wraps an arbitrary writer and aligns tabbed output.
Elastic tabstops work by aligning contiguous tabbed delimited fields
known as column blocks. When a line appears that breaks all contiguous
blocks, all buffered output will be flushed to the underlying writer.
Otherwise, output will stay buffered until flush is explicitly called.
Implementations§
Source§impl<W: Write> TabWriter<W>
impl<W: Write> TabWriter<W>
Sourcepub fn new(w: W) -> TabWriter<W> ⓘ
pub fn new(w: W) -> TabWriter<W> ⓘ
Create a new TabWriter from an existing Writer.
All output written to Writer is passed through TabWriter.
Contiguous column blocks indicated by tabs are aligned.
Note that flush must be called to guarantee that TabWriter will
write to the given writer.
Sourcepub fn minwidth(self, minwidth: usize) -> TabWriter<W> ⓘ
pub fn minwidth(self, minwidth: usize) -> TabWriter<W> ⓘ
Set the minimum width of each column. That is, all columns will have
at least the size given here. If a column is smaller than minwidth,
then it is padded with spaces.
The default minimum width is 2.
Sourcepub fn padding(self, padding: usize) -> TabWriter<W> ⓘ
pub fn padding(self, padding: usize) -> TabWriter<W> ⓘ
Set the padding between columns. All columns will be separated by
at least the number of spaces indicated by padding. If padding
is zero, then columns may run up against each other without any
separation.
The default padding is 2.
Sourcepub fn alignment(self, alignment: Alignment) -> TabWriter<W> ⓘ
pub fn alignment(self, alignment: Alignment) -> TabWriter<W> ⓘ
Set the alignment of text within cells. This will effect future flushes.
The default alignment is Alignment::Left.
Sourcepub fn ansi(self, yes: bool) -> TabWriter<W> ⓘ
pub fn ansi(self, yes: bool) -> TabWriter<W> ⓘ
Ignore ANSI escape codes when computing the number of display columns.
This is disabled by default. (But is enabled by default when the
deprecated ansi_formatting crate feature is enabled.)
Sourcepub fn tab_indent(self, yes: bool) -> TabWriter<W> ⓘ
pub fn tab_indent(self, yes: bool) -> TabWriter<W> ⓘ
Always use tabs for indentation columns (i.e., padding of leading empty cells on the left).
This is disabled by default.
Sourcepub fn into_inner(self) -> Result<W, IntoInnerError<TabWriter<W>>>
pub fn into_inner(self) -> Result<W, IntoInnerError<TabWriter<W>>>
Unwraps this TabWriter, returning the underlying writer.
This internal buffer is flushed before returning the writer. If the flush fails, then an error is returned.
Trait Implementations§
Source§impl<W: Write> Write for TabWriter<W>
impl<W: Write> Write for TabWriter<W>
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)