use coord::{Coord, Size};
use rgb24::Rgb24;
pub trait ViewCell {
fn set_character(&mut self, character: char);
fn set_bold(&mut self, bold: bool);
fn set_underline(&mut self, underline: bool);
fn set_foreground_colour(&mut self, colour: Rgb24);
fn set_background_colour(&mut self, colour: Rgb24);
}
pub trait ViewGrid {
type Cell: ViewCell;
fn get_mut(&mut self, coord: Coord, depth: i32) -> Option<&mut Self::Cell>;
}
pub trait View<T> {
fn view<G: ViewGrid>(&mut self, data: &T, offset: Coord, depth: i32, grid: &mut G);
}
pub trait ViewSize<T> {
fn size(&mut self, data: &T) -> Size;
}
pub trait Renderer {
type Error: ::std::fmt::Debug;
fn render_at<V: View<T>, T>(&mut self, view: &mut V, data: &T, offset: Coord, depth: i32) -> Result<(), Self::Error>;
fn render<V: View<T>, T>(&mut self, view: &mut V, data: &T) -> Result<(), Self::Error> {
self.render_at(view, data, Coord::new(0, 0), 0)
}
}