#[non_exhaustive]
#[derive(Debug, PartialEq)]
pub enum Cell<'a> {
Boolean(bool),
Text(&'a str),
Integer(i64),
Float(f64),
Unsigned(u64),
}
impl From<f64> for Cell<'_> {
fn from(f: f64) -> Self {
Self::Float(f)
}
}
impl<'a> From<&'a str> for Cell<'a> {
fn from(s: &'a str) -> Self {
Self::Text(s)
}
}
impl From<u64> for Cell<'_> {
fn from(u: u64) -> Self {
Self::Unsigned(u)
}
}
impl From<&Cell<'_>> for String {
fn from(c: &Cell) -> String {
match c {
Cell::Boolean(value) => value.to_string(),
Cell::Text(value) => value.to_string(),
Cell::Integer(value) => value.to_string(),
Cell::Float(value) => value.to_string(),
Cell::Unsigned(value) => value.to_string(),
}
}
}
#[derive(Debug, PartialEq)]
pub struct Row<'a> {
pub cells: Vec<Cell<'a>>,
pub chosen: bool,
}
#[derive(Debug, PartialEq)]
pub struct Table<'a> {
pub footer: Vec<Cell<'a>>,
pub header: Vec<Cell<'a>>,
pub rows: Vec<Row<'a>>,
}
pub trait Ui {
fn call_display_table(&self) -> bool;
fn display_table(&self, table: &Table);
fn info(&self, message: &str);
fn prompt_choice(&self, choice: &str) -> bool;
}