add more edn view examples

This commit is contained in:
🪞👃🪞 2025-01-10 19:01:59 +01:00
parent f64a9731ce
commit a8611db452
6 changed files with 34 additions and 17 deletions

View file

@ -10,11 +10,17 @@ pub type EdnRenderCallback<'a, O: Output, State> =
/// Provides values to the template
pub trait EdnViewData<E: Output> {
fn get_bool (&self, _sym: EdnItem<&str>) -> bool { false }
fn get_usize (&self, _sym: EdnItem<&str>) -> usize { 0 }
fn get_content <'a> (&'a self, _sym: EdnItem<&'a str>) -> RenderBox<'a, E> { Box::new(()) }
fn get_bool (&self, _sym: EdnItem<&str>) -> bool {
panic!("no content")
}
fn get_usize (&self, _sym: EdnItem<&str>) -> usize {
panic!("no content")
}
fn get_content <'a> (&'a self, _sym: EdnItem<&'a str>) -> RenderBox<'a, E> {
panic!("no content")
}
fn get_unit (&self, num: EdnItem<&str>) -> E::Unit {
if let EdnItem::Num(n) = num { (n as u16).into() } else { 0.into() }
if let EdnItem::Num(n) = num { (n as u16).into() } else { panic!("not a number") }
}
}