fancy_table

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)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn main() {
    let table = FancyTable::create(FancyTableOpts {
        charset: Charset::Minimal,
        max_lines: 5,
        ..Default::default()
    })
        .add_column_named("ID", Layout::Slim)
        .add_column_named("NAME", Layout::Fixed(16))
        .add_wrapping_column_named_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
        .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
        .add_wrapping_column_named_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
        .hseparator(Some(Separator::Single))
        .build(80);

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

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

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

    table.render(vec![
        &[
            "29",
            "Tauriel",
            "Woodland elf",
            "Tearjerker\n1/10",
            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
        ],
        &[
            "1",
            "Maeglin",
            "Elf",
            "Renegade\n10/10",
            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
        ]
    ]);
}
source

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

Examples found in repository?
examples/minimal.rs (lines 17-32)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn main() {
    let table = FancyTable::create(FancyTableOpts {
        charset: Charset::Minimal,
        max_lines: 5,
        ..Default::default()
    })
        .add_column_named("ID", Layout::Slim)
        .add_column_named("NAME", Layout::Fixed(16))
        .add_wrapping_column_named_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
        .add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
        .add_wrapping_column_named_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
        .hseparator(Some(Separator::Single))
        .build(80);

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

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

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

    table.render(vec![
        &[
            "29",
            "Tauriel",
            "Woodland elf",
            "Tearjerker\n1/10",
            "Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
        ],
        &[
            "1",
            "Maeglin",
            "Elf",
            "Renegade\n10/10",
            "Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
        ]
    ]);
}

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.