pub struct StreamingTableFormatter<'w> {
columns: Vec<CqlColumn>,
colorizer: &'w CqlColorizer,
writer: &'w mut dyn Write,
first_page_buffer: Vec<CqlRow>,
page_size: usize,
header_written: bool,
col_widths: Vec<usize>,
row_count: usize,
expanded: bool,
}Expand description
A streaming table formatter that computes column widths from the first page of results and then formats subsequent rows incrementally.
Fields§
§columns: Vec<CqlColumn>§colorizer: &'w CqlColorizer§writer: &'w mut dyn Write§first_page_buffer: Vec<CqlRow>Buffer for first-page rows used to compute column widths
page_size: usizeMaximum number of rows to buffer for width computation
header_written: boolWhether the header has been written (first page flushed)
col_widths: Vec<usize>Computed column widths (set after first page flush)
row_count: usizeTotal rows written
expanded: boolWhether we’re in expanded mode
Implementations§
Source§impl<'w> StreamingTableFormatter<'w>
impl<'w> StreamingTableFormatter<'w>
Sourcepub fn new(
columns: Vec<CqlColumn>,
colorizer: &'w CqlColorizer,
writer: &'w mut dyn Write,
page_size: usize,
) -> Self
pub fn new( columns: Vec<CqlColumn>, colorizer: &'w CqlColorizer, writer: &'w mut dyn Write, page_size: usize, ) -> Self
Create a new streaming formatter in tabular mode.
Sourcepub fn new_expanded(
columns: Vec<CqlColumn>,
colorizer: &'w CqlColorizer,
writer: &'w mut dyn Write,
) -> Self
pub fn new_expanded( columns: Vec<CqlColumn>, colorizer: &'w CqlColorizer, writer: &'w mut dyn Write, ) -> Self
Create a new streaming formatter in expanded mode.
Sourcepub fn add_row(&mut self, row: CqlRow) -> Result<()>
pub fn add_row(&mut self, row: CqlRow) -> Result<()>
Add a row to the formatter. Returns Err if writing fails (e.g. broken pipe).
pub fn flush_writer(&mut self) -> Result<()>
Sourcepub fn finish(self) -> Result<usize>
pub fn finish(self) -> Result<usize>
Finish the stream: flush any buffered rows and write the footer. Returns the total row count.
Sourcefn flush_first_page(&mut self) -> Result<()>
fn flush_first_page(&mut self) -> Result<()>
Compute column widths from the first page buffer and flush everything.
fn write_separator(&mut self) -> Result<()>
fn write_header_row(&mut self) -> Result<()>
fn write_row(&mut self, row: &CqlRow) -> Result<()>
fn write_expanded_row(&mut self, row: &CqlRow) -> Result<()>
Auto Trait Implementations§
impl<'w> Freeze for StreamingTableFormatter<'w>
impl<'w> !RefUnwindSafe for StreamingTableFormatter<'w>
impl<'w> !Send for StreamingTableFormatter<'w>
impl<'w> !Sync for StreamingTableFormatter<'w>
impl<'w> Unpin for StreamingTableFormatter<'w>
impl<'w> UnsafeUnpin for StreamingTableFormatter<'w>
impl<'w> !UnwindSafe for StreamingTableFormatter<'w>
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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