Struct FancyTable

Source
pub struct FancyTable<'a, T: AsRef<str>> { /* private fields */ }

Implementations§

Source§

impl<'a, T: AsRef<str>> FancyTable<'a, T>

Source

pub fn create(opts: FancyTableOpts) -> FancyTableBuilder<'a, T>

Examples found in repository?
examples/minimal.rs (lines 4-8)
3fn main() {
4    let table = FancyTable::create(FancyTableOpts {
5        charset: Charset::Minimal,
6        max_lines: 5,
7        ..Default::default()
8    })
9    .add_column_named("ID", Layout::Slim)
10    .add_column_named("NAME", Layout::Fixed(16))
11    .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
12    .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
13    .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
14    .hseparator(Some(Separator::Single))
15    .build(80);
16
17    table.render(vec![
18        [
19            "1",
20            "Maeglin",
21            "Elf",
22            "Renegade\n10/10",
23            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
24        ],
25        [
26            "29",
27            "Tauriel",
28            "Woodland elf",
29            "Tearjerker\n1/10",
30            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
31        ]
32    ]);
33}
More examples
Hide additional examples
examples/simple.rs (lines 6-9)
5fn main() {
6    let table = FancyTable::create(FancyTableOpts {
7        charset: Charset::Simple,
8        ..Default::default()
9    })
10    .add_title_with_align("props", TitleAlign::RightOffset(1))
11    .add_column_named("ID", Layout::Slim)
12    .add_column_named("NAME", Layout::Fixed(16))
13    .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
14    .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
15    .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
16    .hseparator(Some(Separator::Single))
17    .padding(1)
18    .build(80);
19
20    table.render(vec![
21        [
22            "1",
23            "Maeglin",
24            "Elf",
25            "Renegade\n10/10",
26            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
27        ],
28        [
29            "29",
30            "Tauriel",
31            "Woodland elf",
32            "Tearjerker\n1/10",
33            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
34        ]
35    ]);
36}
examples/classic.rs (lines 6-9)
5fn main() {
6    let table = FancyTable::create(FancyTableOpts {
7        charset: Charset::Classic,
8        ..Default::default()
9    })
10    .add_title_with_align("props", TitleAlign::RightOffset(1))
11    .add_column_named("ID", Layout::Slim)
12    .add_column_named("NAME", Layout::Fixed(16))
13    .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
14    .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
15    .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
16    .hseparator(Some(Separator::Single))
17    .padding(3)
18    .build(80);
19
20    table.render(vec![
21        [
22            "29",
23            "Tauriel",
24            "Woodland elf",
25            "Tearjerker\n1/10",
26            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
27        ],
28        [
29            "1",
30            "Maeglin",
31            "Elf",
32            "Renegade\n10/10",
33            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
34        ]
35    ]);
36}
examples/modern.rs (line 4)
3fn main() {
4    let table = FancyTable::create(FancyTableOpts::default())
5        .add_title_with_align("props", TitleAlign::RightOffset(1))
6        .add_column_named("ID", Layout::Slim)
7        .add_column_named("NAME", Layout::Fixed(16))
8        .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
9        .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
10        .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
11        .padding(1)
12        .hseparator(Some(Separator::Double))
13        .rseparator(Some(Separator::Custom('┄')))
14        .build(80);
15
16    table.render(vec![
17        [
18            "1",
19            "Maeglin",
20            "Elf",
21            "Renegade\n10/10",
22            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
23        ],
24        [
25            "29",
26            "Tauriel",
27            "Woodland elf",
28            "Tearjerker\n1/10",
29            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
30        ]
31    ]);
32}
Source

pub fn render<R: AsRef<[T]>>(&self, rows: Vec<R>)

Examples found in repository?
examples/minimal.rs (lines 17-32)
3fn main() {
4    let table = FancyTable::create(FancyTableOpts {
5        charset: Charset::Minimal,
6        max_lines: 5,
7        ..Default::default()
8    })
9    .add_column_named("ID", Layout::Slim)
10    .add_column_named("NAME", Layout::Fixed(16))
11    .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
12    .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
13    .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
14    .hseparator(Some(Separator::Single))
15    .build(80);
16
17    table.render(vec![
18        [
19            "1",
20            "Maeglin",
21            "Elf",
22            "Renegade\n10/10",
23            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
24        ],
25        [
26            "29",
27            "Tauriel",
28            "Woodland elf",
29            "Tearjerker\n1/10",
30            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
31        ]
32    ]);
33}
More examples
Hide additional examples
examples/simple.rs (lines 20-35)
5fn main() {
6    let table = FancyTable::create(FancyTableOpts {
7        charset: Charset::Simple,
8        ..Default::default()
9    })
10    .add_title_with_align("props", TitleAlign::RightOffset(1))
11    .add_column_named("ID", Layout::Slim)
12    .add_column_named("NAME", Layout::Fixed(16))
13    .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
14    .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
15    .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
16    .hseparator(Some(Separator::Single))
17    .padding(1)
18    .build(80);
19
20    table.render(vec![
21        [
22            "1",
23            "Maeglin",
24            "Elf",
25            "Renegade\n10/10",
26            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
27        ],
28        [
29            "29",
30            "Tauriel",
31            "Woodland elf",
32            "Tearjerker\n1/10",
33            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
34        ]
35    ]);
36}
examples/classic.rs (lines 20-35)
5fn main() {
6    let table = FancyTable::create(FancyTableOpts {
7        charset: Charset::Classic,
8        ..Default::default()
9    })
10    .add_title_with_align("props", TitleAlign::RightOffset(1))
11    .add_column_named("ID", Layout::Slim)
12    .add_column_named("NAME", Layout::Fixed(16))
13    .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
14    .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
15    .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
16    .hseparator(Some(Separator::Single))
17    .padding(3)
18    .build(80);
19
20    table.render(vec![
21        [
22            "29",
23            "Tauriel",
24            "Woodland elf",
25            "Tearjerker\n1/10",
26            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
27        ],
28        [
29            "1",
30            "Maeglin",
31            "Elf",
32            "Renegade\n10/10",
33            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
34        ]
35    ]);
36}
examples/modern.rs (lines 16-31)
3fn main() {
4    let table = FancyTable::create(FancyTableOpts::default())
5        .add_title_with_align("props", TitleAlign::RightOffset(1))
6        .add_column_named("ID", Layout::Slim)
7        .add_column_named("NAME", Layout::Fixed(16))
8        .add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
9        .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
10        .add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
11        .padding(1)
12        .hseparator(Some(Separator::Double))
13        .rseparator(Some(Separator::Custom('┄')))
14        .build(80);
15
16    table.render(vec![
17        [
18            "1",
19            "Maeglin",
20            "Elf",
21            "Renegade\n10/10",
22            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
23        ],
24        [
25            "29",
26            "Tauriel",
27            "Woodland elf",
28            "Tearjerker\n1/10",
29            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
30        ]
31    ]);
32}

Auto Trait Implementations§

§

impl<'a, T> Freeze for FancyTable<'a, T>

§

impl<'a, T> RefUnwindSafe for FancyTable<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for FancyTable<'a, T>
where T: Send,

§

impl<'a, T> Sync for FancyTable<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for FancyTable<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for FancyTable<'a, T>
where T: 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.