TableData

Struct TableData 

Source
pub struct TableData<T> {
    pub rows: Vec<T>,
    pub columns: Vec<ColumnDef<T>>,
    pub title: Option<String>,
    pub borders: bool,
    pub highlight_symbol: Option<String>,
    pub highlight: bool,
}
Expand description

Generic table data structure

Holds the data and configuration for rendering a table widget. Use the builder pattern methods to construct a table incrementally.

Fields§

§rows: Vec<T>

Rows of data to display

§columns: Vec<ColumnDef<T>>

Column definitions

§title: Option<String>

Optional table title

§borders: bool

Whether to show borders

§highlight_symbol: Option<String>

Highlight symbol for selection

§highlight: bool

Whether to highlight on hover/selection

Implementations§

Source§

impl<T> TableData<T>

Source

pub fn new() -> Self

Create a new empty table

Source

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

Set the table title

Source

pub fn column(self, def: ColumnDef<T>) -> Self

Add a column definition

Source

pub fn rows(self, rows: Vec<T>) -> Self

Set multiple rows of data

Source

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

Set whether to show borders (default: true)

Source

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

Set the highlight symbol (default: “>> “)

Source

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

Set whether to enable highlighting (default: true)

Source

pub fn row(self, row: T) -> Self

Add a single row

Trait Implementations§

Source§

impl<T> Default for TableData<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TableData<T>

§

impl<T> !RefUnwindSafe for TableData<T>

§

impl<T> !Send for TableData<T>

§

impl<T> !Sync for TableData<T>

§

impl<T> Unpin for TableData<T>
where T: Unpin,

§

impl<T> !UnwindSafe for TableData<T>

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, 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

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

Source§

type Error = Infallible

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.