mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: trait EdnCommand
This commit is contained in:
parent
8850fbf2f8
commit
aad7aa6c5e
7 changed files with 193 additions and 165 deletions
|
|
@ -1,26 +0,0 @@
|
|||
use crate::*;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub trait EdnControlData<E: Input> {}
|
||||
|
||||
/// Renders from EDN source and context.
|
||||
#[derive(Default)]
|
||||
pub enum EdnControls<E: Input, T: EdnControlData<E>> {
|
||||
#[default]
|
||||
Inert,
|
||||
_Unused(PhantomData<E>),
|
||||
Ok(T, EdnItem<String>),
|
||||
Err(String)
|
||||
}
|
||||
|
||||
impl<E: Input, T: EdnControlData<E>> EdnControls<E, T> {
|
||||
pub fn from_source (state: T, source: &str) -> Self {
|
||||
match EdnItem::read_one(&source) {
|
||||
Ok((layout, _)) => Self::Ok(state, layout),
|
||||
Err(error) => Self::Err(format!("{error}"))
|
||||
}
|
||||
}
|
||||
pub fn from_items (state: T, items: &[EdnItem<&str>]) -> Self {
|
||||
Self::Ok(state, EdnItem::Exp(items.iter().map(|i|(*i).clone()).collect()))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue