Struct LineText

Source
pub struct LineText<Line> { /* private fields */ }
Expand description

LineText writes a custom text on a border.

§Example

use tabled::{Table, settings::style::LineText, settings::object::Rows};

let mut table = Table::new(["Hello World"]);
table.with(LineText::new("+-.table", Rows::first()));

assert_eq!(
    table.to_string(),
    "+-.table------+\n\
     | &str        |\n\
     +-------------+\n\
     | Hello World |\n\
     +-------------+"
);

Implementations§

Source§

impl<Line> LineText<Line>

Source

pub fn new<S>(text: S, line: Line) -> Self
where S: Into<String>,

Creates a LineText instance.

Line can be a column or a row. Lines are numbered from 0 to the count_rows/count_columns included: (line >= 0 && line <= count_rows) (line >= 0 && line <= count_columns).

use tabled::{Table, settings::style::LineText, settings::object::Columns};

let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Columns::one(0)));
table.with(LineText::new("TABLE", Columns::one(1)));

assert_eq!(
    table.to_string(),
    "T-------------T\n\
     A &str        A\n\
     B-------------B\n\
     L Hello World L\n\
     E-------------E"
);
Source

pub fn align(self, alignment: Alignment) -> Self

Set an offset from which the text will be started.

use tabled::Table;
use tabled::settings::{Alignment, style::LineText, object::Rows};

let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Rows::first()).align(Alignment::center()));

assert_eq!(
    table.to_string(),
    "+----TABLE----+\n\
     | &str        |\n\
     +-------------+\n\
     | Hello World |\n\
     +-------------+"
);
Source

pub fn offset(self, offset: impl Into<Offset>) -> Self

Set an offset from which the text will be started.

use tabled::{Table, settings::style::LineText, settings::object::Rows};

let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Rows::first()).offset(3));

assert_eq!(
    table.to_string(),
    "+--TABLE------+\n\
     | &str        |\n\
     +-------------+\n\
     | Hello World |\n\
     +-------------+"
);
Source

pub fn color(self, color: Color) -> Self

Set a color of the text.

use tabled::Table;
use tabled::settings::{object::Rows, Color, style::LineText};

let mut table = Table::new(["Hello World"]);
table.with(LineText::new("TABLE", Rows::first()).color(Color::FG_BLUE));

assert_eq!(
    table.to_string(),
    "\u{1b}[34mT\u{1b}[39m\u{1b}[34mA\u{1b}[39m\u{1b}[34mB\u{1b}[39m\u{1b}[34mL\u{1b}[39m\u{1b}[34mE\u{1b}[39m---------+\n\
     | &str        |\n\
     +-------------+\n\
     | Hello World |\n\
     +-------------+"
);

Trait Implementations§

Source§

impl<Line: Debug> Debug for LineText<Line>

Source§

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

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

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<Column>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<FirstColumn>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<FirstRow>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumn>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastColumnOffset>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRow>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<LastRowOffset>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<R, D> TableOption<R, ColoredConfig, D> for LineText<Row>
where R: Records + ExactRecords, for<'a> &'a R: Records, for<'a> D: Estimate<&'a R, ColoredConfig> + Dimension,

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more

Auto Trait Implementations§

§

impl<Line> Freeze for LineText<Line>
where Line: Freeze,

§

impl<Line> RefUnwindSafe for LineText<Line>
where Line: RefUnwindSafe,

§

impl<Line> Send for LineText<Line>
where Line: Send,

§

impl<Line> Sync for LineText<Line>
where Line: Sync,

§

impl<Line> Unpin for LineText<Line>
where Line: Unpin,

§

impl<Line> UnwindSafe for LineText<Line>
where Line: UnwindSafe,

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, 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.