1
 2
 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
//! Renderer traits

use crate::{
    layout::{CoordsMapping, Layout},
    widget::unit::WidgetUnit,
};

pub trait Renderer<T, E> {
    fn render(
        &mut self,
        tree: &WidgetUnit,
        mapping: &CoordsMapping,
        layout: &Layout,
    ) -> Result<T, E>;
}

#[derive(Debug, Default, Copy, Clone)]
pub struct RawRenderer;

impl Renderer<WidgetUnit, ()> for RawRenderer {
    fn render(
        &mut self,
        tree: &WidgetUnit,
        _: &CoordsMapping,
        _: &Layout,
    ) -> Result<WidgetUnit, ()> {
        Ok(tree.clone())
    }
}