reactive_graph_flow_model/reactive_graph/flow/
simple_flow.rs

1//! ---------------------------------------------
2//! This file was generated automatically.
3//! ---------------------------------------------
4#![allow(dead_code, unused)]
5#![cfg_attr(rustfmt, rustfmt_skip)]
6
7/// Namespace `reactive_graph::flow::SimpleFlow`
8#[cfg_attr(rustfmt, rustfmt_skip)]
9pub const SIMPLE_FLOW_NAMESPACE: &str = "reactive_graph::flow::SimpleFlow";
10
11/// The [type identifier]() of EntityType `SimpleFlow`.
12///
13/// ### Namespace
14///
15/// The fully qualified namespace is
16/// `reactive_graph::flow::SimpleFlow`
17pub static SIMPLE_FLOW: std::sync::LazyLock<reactive_graph_graph::EntityTypeId> = std::sync::LazyLock::new(||
18std::str::FromStr::from_str(SIMPLE_FLOW_NAMESPACE).unwrap());
19
20/// The properties of EntityType `SimpleFlow`.
21#[allow(non_camel_case_types)]
22#[derive(Debug, PartialEq, PartialOrd, Eq, Hash, Clone)]
23pub enum SimpleFlowProperties {
24    
25    /// ### Property `input`
26    ///
27    /// Flow input
28    ///
29    /// Data Type: `Object`
30    ///
31    /// Socket Type: `Input`
32    ///
33    /// Mutability: `Mutable`
34    ///
35    INPUT,
36    
37    /// ### Property `output`
38    ///
39    /// Flow output
40    ///
41    /// Data Type: `Object`
42    ///
43    /// Socket Type: `Output`
44    ///
45    /// Mutability: `Mutable`
46    ///
47    OUTPUT,
48}
49impl SimpleFlowProperties {
50    pub fn len() -> usize {
51        2usize
52    }
53    
54    pub fn property_types() -> reactive_graph_graph::PropertyTypes {
55        let property_types = reactive_graph_graph::PropertyTypes::new();
56        property_types.push(SimpleFlowProperties::INPUT);
57        property_types.push(SimpleFlowProperties::OUTPUT);
58        property_types
59    }
60}
61
62impl AsRef<str> for SimpleFlowProperties {
63    #[inline]
64    fn as_ref(&self) -> &str {
65        match *self {
66            SimpleFlowProperties::INPUT => "input",
67            SimpleFlowProperties::OUTPUT => "output",
68        }
69    }
70}
71
72impl From<SimpleFlowProperties> for &'static str {
73    #[inline]
74    fn from(properties: SimpleFlowProperties) -> &'static str {
75        match properties {
76            SimpleFlowProperties::INPUT => "input",
77            SimpleFlowProperties::OUTPUT => "output",
78        }
79    }
80}
81
82impl From<SimpleFlowProperties> for String {
83    #[inline]
84    fn from(properties: SimpleFlowProperties) -> String {
85        match properties {
86            SimpleFlowProperties::INPUT => "input".to_owned(),
87            SimpleFlowProperties::OUTPUT => "output".to_owned(),
88        }
89    }
90}
91
92impl From<SimpleFlowProperties> for reactive_graph_graph::PropertyType {
93    #[inline]
94    fn from(properties: SimpleFlowProperties) -> reactive_graph_graph::PropertyType {
95        match properties {
96            SimpleFlowProperties::INPUT => {
97                reactive_graph_graph::PropertyType::new_with_all(
98                    "input",
99                    "Flow input",
100                    reactive_graph_graph::DataType::Object,
101                    reactive_graph_graph::SocketType::Input,
102                    reactive_graph_graph::Mutability::Mutable,
103                    reactive_graph_graph::Extensions::new(),
104                )
105            }
106            SimpleFlowProperties::OUTPUT => {
107                reactive_graph_graph::PropertyType::new_with_all(
108                    "output",
109                    "Flow output",
110                    reactive_graph_graph::DataType::Object,
111                    reactive_graph_graph::SocketType::Output,
112                    reactive_graph_graph::Mutability::Mutable,
113                    reactive_graph_graph::Extensions::new(),
114                )
115            }
116        }
117    }
118}
119
120pub struct SimpleFlowPropertiesIterator(Option<SimpleFlowProperties>);
121
122impl SimpleFlowProperties {
123    pub fn into_iter() -> SimpleFlowPropertiesIterator {
124        SimpleFlowPropertiesIterator(None)
125    }
126}
127
128impl Iterator for SimpleFlowPropertiesIterator {
129    type Item = SimpleFlowProperties;
130    fn next(&mut self) -> Option<Self::Item> {
131        self.0 = match self.0 {
132            None => Some(SimpleFlowProperties::INPUT),
133            Some(SimpleFlowProperties::INPUT) => Some(SimpleFlowProperties::OUTPUT),
134            Some(SimpleFlowProperties::OUTPUT) => None,
135        };
136        self.0.clone()
137    }
138}
139
140impl IntoIterator for SimpleFlowProperties {
141    type Item = SimpleFlowProperties;
142    type IntoIter = SimpleFlowPropertiesIterator;
143    fn into_iter(self) -> Self::IntoIter {
144        SimpleFlowPropertiesIterator(None)
145    }
146}
147
148impl core::fmt::Display for SimpleFlowProperties {
149    fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
150        match *self {
151            SimpleFlowProperties::INPUT => core::fmt::Display::fmt("input", f),
152            SimpleFlowProperties::OUTPUT => core::fmt::Display::fmt("output", f),
153        }
154    }
155}
156
157///
158pub static SIMPLE_FLOW_COMPONENTS: std::sync::LazyLock<
159    reactive_graph_graph::ComponentTypeIds,
160> = std::sync::LazyLock::new(|| { reactive_graph_graph::ComponentTypeIds::new() });
161
162///
163pub static SIMPLE_FLOW_EXTENSIONS: std::sync::LazyLock<
164    reactive_graph_graph::Extensions,
165> = std::sync::LazyLock::new(|| { reactive_graph_graph::Extensions::new() });
166
167pub static SIMPLE_FLOW_TYPE: std::sync::LazyLock<reactive_graph_graph::EntityType> = std::sync::LazyLock::new(||
168{
169    reactive_graph_graph::EntityType::builder()
170        .ty(core::ops::Deref::deref(&SIMPLE_FLOW))
171        .description("A simple generic flow with a single input and a single output")
172        .components(SIMPLE_FLOW_COMPONENTS.clone())
173        .properties(SimpleFlowProperties::property_types())
174        .extensions(SIMPLE_FLOW_EXTENSIONS.clone())
175        .build()
176});
177
178/// # EntityType `SimpleFlow`
179///
180/// ## Fully Qualified Namespace
181///
182/// `reactive_graph::flow::SimpleFlow`
183///
184/// ## Description
185///
186/// A simple generic flow with a single input and a single output
187///
188/// ### Properties
189///
190/// - input
191/// - output
192///
193/// ## JSON Schema
194///
195/// [https://schema.reactive-graph.io/schema/json/dynamic_graph/types/entity/reactive_graph/flow/SimpleFlow.schema.json]()
196///
197#[derive(
198    Debug,
199    Clone,
200    PartialEq,
201    Eq,
202    serde::Serialize,
203    serde::Deserialize,
204    typed_builder::TypedBuilder
205)]
206pub struct SimpleFlow {
207    #[builder(default, setter(into))]
208    pub id: uuid::Uuid,
209    
210    /// ### Property `input`
211    ///
212    /// Flow input
213    ///
214    /// Data Type: `Object`
215    ///
216    /// Socket Type: `Input`
217    ///
218    /// Mutability: `Mutable`
219    ///
220    #[builder(setter(into))]
221    pub input: serde_json::Map<String, serde_json::Value>,
222    
223    /// ### Property `output`
224    ///
225    /// Flow output
226    ///
227    /// Data Type: `Object`
228    ///
229    /// Socket Type: `Output`
230    ///
231    /// Mutability: `Mutable`
232    ///
233    #[builder(setter(into))]
234    pub output: serde_json::Map<String, serde_json::Value>,
235    #[builder(default, setter(into))]
236    pub extensions: reactive_graph_graph::Extensions,
237}
238
239impl SimpleFlow {
240    pub fn new(
241        input: serde_json::Map<String, serde_json::Value>,
242        output: serde_json::Map<String, serde_json::Value>,
243    ) -> Self {
244        Self {
245            id: uuid::Uuid::new_v4(),
246            input,
247            output,
248            extensions: reactive_graph_graph::Extensions::new(),
249        }
250    }
251    pub fn new_with_id(
252        id: uuid::Uuid,
253        input: serde_json::Map<String, serde_json::Value>,
254        output: serde_json::Map<String, serde_json::Value>,
255    ) -> Self {
256        Self {
257            id,
258            input,
259            output,
260            extensions: reactive_graph_graph::Extensions::new(),
261        }
262    }
263    pub fn new_with_extensions(
264        id: uuid::Uuid,
265        input: serde_json::Map<String, serde_json::Value>,
266        output: serde_json::Map<String, serde_json::Value>,
267        extensions: reactive_graph_graph::Extensions,
268    ) -> Self {
269        Self {
270            id,
271            input,
272            output,
273            extensions,
274        }
275    }
276    
277    pub fn id(&self) -> uuid::Uuid {
278        self.id
279    }
280    
281    /// ### Property `input`
282    ///
283    /// Flow input
284    ///
285    /// Data Type: `Object`
286    ///
287    /// Socket Type: `Input`
288    ///
289    /// Mutability: `Mutable`
290    ///
291    pub fn input(&self) -> serde_json::Map<String, serde_json::Value> {
292        self.input.clone()
293    }
294    
295    /// ### Property `input`
296    ///
297    /// Flow input
298    ///
299    /// Data Type: `Object`
300    ///
301    /// Socket Type: `Input`
302    ///
303    /// Mutability: `Mutable`
304    ///
305    pub fn set_input(&mut self, input: serde_json::Map<String, serde_json::Value>) {
306        self.input = input;
307    }
308    
309    /// ### Property `output`
310    ///
311    /// Flow output
312    ///
313    /// Data Type: `Object`
314    ///
315    /// Socket Type: `Output`
316    ///
317    /// Mutability: `Mutable`
318    ///
319    pub fn output(&self) -> serde_json::Map<String, serde_json::Value> {
320        self.output.clone()
321    }
322    
323    /// ### Property `output`
324    ///
325    /// Flow output
326    ///
327    /// Data Type: `Object`
328    ///
329    /// Socket Type: `Output`
330    ///
331    /// Mutability: `Mutable`
332    ///
333    pub fn set_output(&mut self, output: serde_json::Map<String, serde_json::Value>) {
334        self.output = output;
335    }
336    
337    pub fn properties(&self) -> reactive_graph_graph::PropertyInstances {
338        reactive_graph_graph::PropertyInstances::new()
339            .property(SimpleFlowProperties::INPUT, self.input.clone())
340            .property(SimpleFlowProperties::OUTPUT, self.output.clone())
341    }
342    
343    pub fn extensions(&self) -> reactive_graph_graph::Extensions {
344        self.extensions.clone()
345    }
346}
347
348impl From<SimpleFlow> for reactive_graph_graph::EntityInstance {
349    fn from(simple_flow: SimpleFlow) -> Self {
350        reactive_graph_graph::EntityInstance::builder()
351            .ty(std::ops::Deref::deref(&SIMPLE_FLOW))
352            .id(simple_flow.id())
353            .components(SIMPLE_FLOW_COMPONENTS.clone())
354            .properties(simple_flow.properties())
355            .build()
356    }
357}
358
359impl TryFrom<reactive_graph_graph::EntityInstance> for SimpleFlow {
360    type Error = ();
361    fn try_from(
362        entity_instance: reactive_graph_graph::EntityInstance,
363    ) -> Result<Self, Self::Error> {
364        Err(())
365    }
366}