Skip to main content

TableColumn

Struct TableColumn 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§field: String

JSON 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: String

Display header.

§no_truncate: bool

When 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: Alignment

Header and cell text alignment — see TableColumn::align.

Implementations§

Source§

impl TableColumn

Source

pub fn new(field: impl Into<String>, header: impl Into<String>) -> Self

Creates a table column from a JSON field path and display header.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> TableColumn

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableColumn

Source§

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

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

impl Eq for TableColumn

Source§

impl PartialEq for TableColumn

Source§

fn eq(&self, other: &TableColumn) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TableColumn

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, <T as TryFrom<U>>::Error>

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