mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
update examples
This commit is contained in:
parent
0e821e098f
commit
400fd9b6e9
9 changed files with 12 additions and 45 deletions
|
|
@ -9,6 +9,7 @@ pub type EdnCallback<'a, Output, State> =
|
|||
pub type EdnRenderCallback<'a, Output, State> =
|
||||
Box<EdnCallback<'a, Output, State>>;
|
||||
|
||||
/// Provides values to the template
|
||||
pub trait EdnViewData<E: Output> {
|
||||
fn get_bool (&self, _sym: EdnItem<&str>) -> bool { false }
|
||||
fn get_unit (&self, _sym: EdnItem<&str>) -> E::Unit { 0.into() }
|
||||
|
|
@ -25,9 +26,11 @@ pub enum EdnView<E: Output, T: EdnViewData<E>> {
|
|||
}
|
||||
|
||||
impl<E: Output, T: EdnViewData<E>> EdnView<E, T> {
|
||||
pub fn new (context: T, source: &str) -> Usually<Self> {
|
||||
let layout = EdnItem::read_one(&source)?.0;
|
||||
Ok(Self::Ok(context, layout))
|
||||
pub fn new (state: T, source: &str) -> Self {
|
||||
match EdnItem::read_one(&source) {
|
||||
Ok((layout, _)) => Self::Ok(state, layout),
|
||||
Err(error) => Self::Err(format!("{error}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue