Trait text_grid::CellSource

source ·
pub trait CellSource {
    // Required method
    fn fmt(&self, s: &mut String);

    // Provided methods
    fn style(&self) -> CellStyle { ... }
    fn style_for_body(&self) -> CellStyle { ... }
}
Expand description

A data structure that can be formatted into cell.

Normally, cell() or cell! is used to create a value that implements CellSource.

If you implement CellSource for a type, you should also implement CellsSource for convenience.

use text_grid::*;
struct X(String);

impl CellSource for X {
    fn fmt(&self, s: &mut String) {
        s.push_str(&self.0);
    }
    fn style(&self) -> CellStyle {
        CellStyle::new().align_h(HorizontalAlignment::Right)
    }
}
impl CellsSource for X {
    fn fmt(f: &mut CellsFormatter<&Self>) {
        f.content(|x| Cell::new(*x));
    }
}

Required Methods§

source

fn fmt(&self, s: &mut String)

Output the cell text to given buffer.

Provided Methods§

source

fn style(&self) -> CellStyle

Return cell’s style.

source

fn style_for_body(&self) -> CellStyle

Implementations on Foreign Types§

source§

impl CellSource for isize

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for u128

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for char

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: CellSource> CellSource for Option<T>

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for i64

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for String

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: CellSource, E: CellSource> CellSource for Result<T, E>

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: ?Sized + CellSource> CellSource for &mut T

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for str

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for ()

source§

fn fmt(&self, _: &mut String)

source§

impl CellSource for i32

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for u16

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for bool

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for i8

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for usize

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for u32

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for i128

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for i16

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for u64

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

source§

impl<T: ?Sized + CellSource> CellSource for &T

source§

fn fmt(&self, s: &mut String)

source§

fn style(&self) -> CellStyle

source§

fn style_for_body(&self) -> CellStyle

source§

impl CellSource for u8

source§

fn fmt(&self, s: &mut String)

source§

fn style_for_body(&self) -> CellStyle

Implementors§