#[non_exhaustive]pub struct TableColumn {
pub field: String,
pub header: String,
pub no_truncate: bool,
pub nested: Option<Vec<TableColumn>>,
pub align: Alignment,
}Expand description
Column definition for registered human table views.
Column order is a priority order, most important first: table rendering keeps this order on screen, and when the terminal is too narrow to show every column, the lowest-priority (trailing) columns are hidden first. Put the column a reader most needs — usually an id or name — first.
This declared order is only the fallback — whenever a --fields/
default_fields selection is given, its order wins instead (see
crate::output::render_human_with_registry_selected), for both display
and hide-priority. Declared order only governs output when no selection is
given at all.
Construct with TableColumn::new, then chain builder methods like
no_truncate/nested
— never as a struct literal. No known consumer constructs TableColumn
via struct literal, so marking it #[non_exhaustive] carries no real
breaking impact today; going forward it means the engine can add fields
(as it did for nested) without that becoming a breaking release either.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.field: StringJSON field path. Supports simple dotted paths to reach a value nested
under intermediate objects, so a column can point through a wrapper
shape (a pagination envelope, a Summary<T>, etc.). A literal field
name containing a . is not supported — this mirrors the dotted-path
convention crate::output::fields already uses for --fields
projection.
header: StringDisplay header.
no_truncate: boolWhen true, this column’s values are never shrunk to fit the terminal
(still capped at NO_TRUNCATE_MAX_WIDTH to bound pathologically long
values). Use this for values that are useless when cut short, such as
URLs.
nested: Option<Vec<TableColumn>>When set, and the resolved value is list-of-objects or object shaped,
this column renders as an indented child table or child property bag
instead of a one-line dump — see TableColumn::nested. None (the
default from TableColumn::new) is a complete no-op: rendering is
identical to a column with no opinion about nesting.
align: AlignmentHeader and cell text alignment — see TableColumn::align.
Implementations§
Source§impl TableColumn
impl TableColumn
Sourcepub fn new(field: impl Into<String>, header: impl Into<String>) -> Self
pub fn new(field: impl Into<String>, header: impl Into<String>) -> Self
Creates a table column from a JSON field path and display header.
Sourcepub fn no_truncate(self, value: bool) -> Self
pub fn no_truncate(self, value: bool) -> Self
Opts this column out of terminal-width-driven shrinking. Values are
still capped at NO_TRUNCATE_MAX_WIDTH.
Sourcepub fn align(self, alignment: Alignment) -> Self
pub fn align(self, alignment: Alignment) -> Self
Sets this column’s header and cell alignment. Defaults to
Alignment::Left; use Alignment::Right for numeric or price
columns so decimal points and digits line up instead of looking
ragged on the left.
Sourcepub fn nested(self, columns: impl Into<Vec<TableColumn>>) -> Self
pub fn nested(self, columns: impl Into<Vec<TableColumn>>) -> Self
Opts this column into rendering a nested list/object value as an
indented child table or property bag, using columns as that child’s
own column definitions (which may themselves set .nested(...)).
Nesting is only consulted when this column is rendered inside an
object property bag (top-level, or itself a nested property bag) — a
row cell inside an array-of-objects table always renders as a single
flat value, ignoring nested, because a table row is one monospace
line and can’t itself contain a rendered sub-block without breaking
column alignment. Recursion is otherwise unbounded through the object
chain: a nested column’s own child columns may set .nested(...)
again for a grandchild table or property bag.
Trait Implementations§
Source§impl Clone for TableColumn
impl Clone for TableColumn
Source§fn clone(&self) -> TableColumn
fn clone(&self) -> TableColumn
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableColumn
impl Debug for TableColumn
impl Eq for TableColumn
Source§impl PartialEq for TableColumn
impl PartialEq for TableColumn
impl StructuralPartialEq for TableColumn
Auto Trait Implementations§
impl Freeze for TableColumn
impl RefUnwindSafe for TableColumn
impl Send for TableColumn
impl Sync for TableColumn
impl Unpin for TableColumn
impl UnsafeUnpin for TableColumn
impl UnwindSafe for TableColumn
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.