reactive_graph_table_model/instances/
flows.rs

1use crate::container::TableInlineFormat;
2use crate::container::TableInlineFormatSetter;
3use crate::container::TableOptions;
4use reactive_graph_graph::NamespacedTypeGetter;
5use tabled::Table;
6use tabled::Tabled;
7use tabled::settings::Modify;
8use tabled::settings::Style;
9use tabled::settings::Width;
10use tabled::settings::object::Segment;
11
12#[derive(Clone, Debug, Tabled)]
13pub struct FlowInstance {
14    /// The type namespace.
15    pub namespace: String,
16
17    /// The type name.
18    pub name: String,
19
20    /// Textual description of the flow instance.
21    pub description: String,
22
23    // pub extensions: Vec<Extension>,
24    #[tabled(skip)]
25    inline_format: TableInlineFormat,
26}
27
28impl TableInlineFormatSetter for FlowInstance {
29    fn set_table_inline_format(&mut self, table_inline_format: TableInlineFormat) {
30        self.inline_format = table_inline_format;
31    }
32}
33
34impl From<reactive_graph_graph::FlowInstance> for FlowInstance {
35    fn from(flow_instance: reactive_graph_graph::FlowInstance) -> Self {
36        FlowInstance {
37            namespace: flow_instance.namespace(),
38            name: flow_instance.type_name(),
39            description: flow_instance.description,
40            inline_format: Default::default(),
41        }
42    }
43}
44
45pub struct FlowInstancesTableOptions;
46
47impl TableOptions for FlowInstancesTableOptions {
48    fn options(table: &mut Table) -> &mut Table {
49        table.with(Style::extended()).with(
50            Modify::new(Segment::new(0.., 0..3))
51                .with(Width::increase(22))
52                .with(Width::increase(22))
53                .with(Width::wrap(40).keep_words(true)),
54        )
55    }
56}