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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::manifest::description::{Layer, PackFlow};
use rill_protocol::flow::core::Flow;
use rill_protocol::io::provider::StreamType;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelectorSpec {
pub label: String,
pub options: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelectorState {
pub spec: SelectorSpec,
pub selected: Option<String>,
}
impl From<SelectorSpec> for SelectorState {
fn from(spec: SelectorSpec) -> Self {
Self {
spec,
selected: None,
}
}
}
impl PackFlow for SelectorState {
fn layer() -> Layer {
Layer::Control
}
}
impl Flow for SelectorState {
type Action = SelectorAction;
type Event = SelectorEvent;
fn stream_type() -> StreamType {
StreamType::from(module_path!())
}
fn apply(&mut self, event: Self::Event) {
self.selected = event.update_selected;
}
}
pub type SelectorAction = Option<String>;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SelectorEvent {
pub update_selected: Option<String>,
}