Skip to main content

StreamingTable

Struct StreamingTable 

Source
pub struct StreamingTable<K> { /* private fields */ }
Expand description

Keyed rows rendered incrementally; see the module docs.

K is the stable row key (a job id, a path, a sequence number). Cells are Values shown through each Column’s formatter; the frame (title, caption, box, edges, expand, border style) is set with the same builders as TableData.

Implementations§

Source§

impl<K> StreamingTable<K>

Source

pub fn title(self, title: impl Into<String>) -> Self

A centered title above the table (console markup, as the core Table::title).

Source

pub fn caption(self, caption: impl Into<String>) -> Self

A centered caption below the table (console markup).

Source

pub fn box_set(self, box_set: Box) -> Self

The box-drawing set (default HEAVY_HEAD, as the core table).

Source

pub fn without_box(self) -> Self

Draw no borders and no column dividers.

Source

pub fn show_edge(self, show: bool) -> Self

Draw the outer edges (default on).

Source

pub fn expand(self, expand: bool) -> Self

Expand to the full available width.

Source

pub fn border_style(self, style: Style) -> Self

Style the box border.

Source§

impl<K: Eq + Hash + Clone> StreamingTable<K>

Source

pub fn new(columns: impl IntoIterator<Item = Column>) -> Self

An empty table under columns.

Source

pub fn window(self, window: Window) -> Self

Show only part of the rows.

Source

pub fn set_window(&mut self, window: Window)

Change the window.

Source

pub fn capacity(self, rows: usize) -> Self

Keep at most rows rows: inserting beyond that evicts the oldest (first inserted). Evicted rows count as earlier rows in the indicator.

Source

pub fn set_sort(&mut self, keys: impl IntoIterator<Item = SortKey>)

Show rows sorted by keys (stable over insertion order, empty cells last), with header indicators; an empty list restores insertion order. Sorting reorders cached rows without re-rendering them.

Source

pub fn sort_by(self, keys: impl IntoIterator<Item = SortKey>) -> Self

Builder form of set_sort.

Source

pub fn upsert(&mut self, key: K, row: impl IntoIterator<Item = Value>) -> bool

Insert a row, or replace the row under key in place (it keeps its position). Returns true when the key is new. Missing cells are Null; extra cells are dropped. Writing identical values is not a change and does not re-render the row.

Source

pub fn update_cell( &mut self, key: &K, column: usize, value: impl Into<Value>, ) -> bool

Set one cell of the row under key. Returns false when there is no such row or column.

Source

pub fn remove(&mut self, key: &K) -> Option<Vec<Value>>

Remove the row under key, returning its cells.

Source

pub fn clear(&mut self)

Remove every row (the evicted count is kept).

Source

pub fn get(&self, key: &K) -> Option<&[Value]>

The cells of the row under key.

Source

pub fn contains_key(&self, key: &K) -> bool

Whether a row is stored under key.

Source

pub fn len(&self) -> usize

The number of stored rows (shown or not).

Source

pub fn is_empty(&self) -> bool

Whether no rows are stored.

Source

pub fn evicted(&self) -> u64

How many rows capacity has evicted.

Source

pub fn columns(&self) -> &[Column]

The columns.

Source

pub fn rows(&self) -> impl Iterator<Item = (&K, &[Value])> + '_

Stored rows in insertion order.

Source

pub fn stats(&self) -> RenderStats

Render-cache counters since creation (or reset_stats).

Source

pub fn reset_stats(&self)

Zero the counters.

Source

pub fn invalidate(&self)

Drop every cached row so the next frame renders from scratch. Needed only when rendering to a console with a different theme, since cached lines keep the styles they were rendered with.

Source

pub fn to_data(&self) -> TableData

A snapshot of every stored row, in display order, with the same columns and sort — for grouping and aggregates.

Source

pub fn to_table(&self, console: &Console) -> Table

The shown rows as one core table, rendered from scratch (without the window’s indicator lines).

Trait Implementations§

Source§

impl<K: Eq + Hash + Clone> AccessibleText for StreamingTable<K>

Source§

fn accessible_text(&self, width: usize) -> String

The content as plain lines, laid out for width where layout matters.
Source§

impl<K> Debug for StreamingTable<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Eq + Hash + Clone> Renderable for StreamingTable<K>

Source§

fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Source§

fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement

The (minimum, maximum) cell width this renderable wants. The default assumes the renderable fills the available width (e.g. Panel, Table); Text overrides it with its content width so the top-level print path can shrink to fit. Port of __rich_measure__ / Measurement.get.
Source§

fn fit_to_measurement(&self) -> bool

Whether a top-level Console::print shrinks this renderable to its measured width. Upstream renders every top-level renderable at the full console width, so the default is false; an extension may opt in.
Source§

fn vertical(&self) -> Option<VerticalAlign>

The vertical alignment a Table cell holding this renderable uses in place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.

Auto Trait Implementations§

§

impl<K> !Freeze for StreamingTable<K>

§

impl<K> !RefUnwindSafe for StreamingTable<K>

§

impl<K> !UnwindSafe for StreamingTable<K>

§

impl<K> Send for StreamingTable<K>
where BTreeMap<u64, Entry<K>>: Send, HashMap<K, u64>: Send,

§

impl<K> Sync for StreamingTable<K>
where BTreeMap<u64, Entry<K>>: Sync, HashMap<K, u64>: Sync,

§

impl<K> Unpin for StreamingTable<K>
where BTreeMap<u64, Entry<K>>: Unpin, HashMap<K, u64>: Unpin,

§

impl<K> UnsafeUnpin for StreamingTable<K>
where BTreeMap<u64, Entry<K>>: UnsafeUnpin, HashMap<K, u64>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more