reactive_graph_runtime_model/reactive_graph/runtime/
shutdown.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::runtime::Shutdown`
8#[cfg_attr(rustfmt, rustfmt_skip)]
9pub const SHUTDOWN_NAMESPACE: &str = "reactive_graph::runtime::Shutdown";
10
11/// The [type identifier]() of EntityType `Shutdown`.
12///
13/// ### Namespace
14///
15/// The fully qualified namespace is
16/// `reactive_graph::runtime::Shutdown`
17pub static SHUTDOWN: std::sync::LazyLock<reactive_graph_graph::EntityTypeId> = std::sync::LazyLock::new(||
18std::str::FromStr::from_str(SHUTDOWN_NAMESPACE).unwrap());
19
20/// The properties of EntityType `Shutdown`.
21#[allow(non_camel_case_types)]
22#[derive(Debug, PartialEq, PartialOrd, Eq, Hash, Clone)]
23pub enum ShutdownProperties {
24    
25    /// ### Property `delay`
26    ///
27    /// Data Type: `Number`
28    ///
29    /// Socket Type: `None`
30    ///
31    /// Mutability: `Mutable`
32    ///
33    DELAY,
34    
35    /// ### Property `label`
36    ///
37    /// Hierarchical path with static segments, named parameters and catch-all parameters
38    ///
39    /// Data Type: `String`
40    ///
41    /// Socket Type: `None`
42    ///
43    /// Mutability: `Mutable`
44    ///
45    LABEL,
46    
47    /// ### Property `trigger`
48    ///
49    /// On receiving a boolean trigger the action will be executed
50    ///
51    /// Data Type: `Bool`
52    ///
53    /// Socket Type: `Input`
54    ///
55    /// Mutability: `Mutable`
56    ///
57    TRIGGER,
58}
59impl ShutdownProperties {
60    pub fn len() -> usize {
61        3usize
62    }
63    
64    pub fn property_types() -> reactive_graph_graph::PropertyTypes {
65        let property_types = reactive_graph_graph::PropertyTypes::new();
66        property_types.push(ShutdownProperties::DELAY);
67        property_types.push(ShutdownProperties::LABEL);
68        property_types.push(ShutdownProperties::TRIGGER);
69        property_types
70    }
71}
72
73impl AsRef<str> for ShutdownProperties {
74    #[inline]
75    fn as_ref(&self) -> &str {
76        match *self {
77            ShutdownProperties::DELAY => "delay",
78            ShutdownProperties::LABEL => "label",
79            ShutdownProperties::TRIGGER => "trigger",
80        }
81    }
82}
83
84impl From<ShutdownProperties> for &'static str {
85    #[inline]
86    fn from(properties: ShutdownProperties) -> &'static str {
87        match properties {
88            ShutdownProperties::DELAY => "delay",
89            ShutdownProperties::LABEL => "label",
90            ShutdownProperties::TRIGGER => "trigger",
91        }
92    }
93}
94
95impl From<ShutdownProperties> for String {
96    #[inline]
97    fn from(properties: ShutdownProperties) -> String {
98        match properties {
99            ShutdownProperties::DELAY => "delay".to_owned(),
100            ShutdownProperties::LABEL => "label".to_owned(),
101            ShutdownProperties::TRIGGER => "trigger".to_owned(),
102        }
103    }
104}
105
106impl From<ShutdownProperties> for reactive_graph_graph::PropertyType {
107    #[inline]
108    fn from(properties: ShutdownProperties) -> reactive_graph_graph::PropertyType {
109        match properties {
110            ShutdownProperties::DELAY => {
111                reactive_graph_graph::PropertyType::new_with_all(
112                    "delay",
113                    "",
114                    reactive_graph_graph::DataType::Number,
115                    reactive_graph_graph::SocketType::None,
116                    reactive_graph_graph::Mutability::Mutable,
117                    reactive_graph_graph::Extensions::new(),
118                )
119            }
120            ShutdownProperties::LABEL => {
121                reactive_graph_graph::PropertyType::new_with_all(
122                    "label",
123                    "Hierarchical path with static segments, named parameters and catch-all parameters",
124                    reactive_graph_graph::DataType::String,
125                    reactive_graph_graph::SocketType::None,
126                    reactive_graph_graph::Mutability::Mutable,
127                    reactive_graph_graph::Extensions::new(),
128                )
129            }
130            ShutdownProperties::TRIGGER => {
131                reactive_graph_graph::PropertyType::new_with_all(
132                    "trigger",
133                    "On receiving a boolean trigger the action will be executed",
134                    reactive_graph_graph::DataType::Bool,
135                    reactive_graph_graph::SocketType::Input,
136                    reactive_graph_graph::Mutability::Mutable,
137                    reactive_graph_graph::Extensions::new(),
138                )
139            }
140        }
141    }
142}
143
144pub struct ShutdownPropertiesIterator(Option<ShutdownProperties>);
145
146impl ShutdownProperties {
147    pub fn into_iter() -> ShutdownPropertiesIterator {
148        ShutdownPropertiesIterator(None)
149    }
150}
151
152impl Iterator for ShutdownPropertiesIterator {
153    type Item = ShutdownProperties;
154    fn next(&mut self) -> Option<Self::Item> {
155        self.0 = match self.0 {
156            None => Some(ShutdownProperties::DELAY),
157            Some(ShutdownProperties::DELAY) => Some(ShutdownProperties::LABEL),
158            Some(ShutdownProperties::LABEL) => Some(ShutdownProperties::TRIGGER),
159            Some(ShutdownProperties::TRIGGER) => None,
160        };
161        self.0.clone()
162    }
163}
164
165impl IntoIterator for ShutdownProperties {
166    type Item = ShutdownProperties;
167    type IntoIter = ShutdownPropertiesIterator;
168    fn into_iter(self) -> Self::IntoIter {
169        ShutdownPropertiesIterator(None)
170    }
171}
172
173impl core::fmt::Display for ShutdownProperties {
174    fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
175        match *self {
176            ShutdownProperties::DELAY => core::fmt::Display::fmt("delay", f),
177            ShutdownProperties::LABEL => core::fmt::Display::fmt("label", f),
178            ShutdownProperties::TRIGGER => core::fmt::Display::fmt("trigger", f),
179        }
180    }
181}
182
183/// ## Components
184///
185/// | Component                       | Description                                                                                       | Properties                          |
186/// |---------------------------------|---------------------------------------------------------------------------------------------------|-------------------------------------|
187/// | `reactive_graph::core::Action`  | An action can be triggered                                                                        | <ul compact><li>`trigger`</li></ul> |
188/// | `reactive_graph::core::Labeled` | The label is a hierarchical path with static segments, named parameters and catch-all parameters. | <ul compact><li>`label`</li></ul>   |
189///
190pub static SHUTDOWN_COMPONENTS: std::sync::LazyLock<
191    reactive_graph_graph::ComponentTypeIds,
192> = std::sync::LazyLock::new(|| {
193    reactive_graph_graph::ComponentTypeIds::new()
194        .component(
195            std::ops::Deref::deref(
196                &reactive_graph_model_core::reactive_graph::core::action::ACTION,
197            ),
198        )
199        .component(
200            std::ops::Deref::deref(
201                &reactive_graph_model_core::reactive_graph::core::labeled::LABELED,
202            ),
203        )
204});
205
206///
207pub static SHUTDOWN_EXTENSIONS: std::sync::LazyLock<reactive_graph_graph::Extensions> = std::sync::LazyLock::new(||
208{ reactive_graph_graph::Extensions::new() });
209
210pub static SHUTDOWN_TYPE: std::sync::LazyLock<reactive_graph_graph::EntityType> = std::sync::LazyLock::new(||
211{
212    reactive_graph_graph::EntityType::builder()
213        .ty(core::ops::Deref::deref(&SHUTDOWN))
214        .description("Shutting down the runtime")
215        .components(SHUTDOWN_COMPONENTS.clone())
216        .properties(ShutdownProperties::property_types())
217        .extensions(SHUTDOWN_EXTENSIONS.clone())
218        .build()
219});
220
221/// # EntityType `Shutdown`
222///
223/// ## Fully Qualified Namespace
224///
225/// `reactive_graph::runtime::Shutdown`
226///
227/// ## Description
228///
229/// Shutting down the runtime
230///
231/// ## Components
232///
233/// | Component                       | Description                                                                                       | Properties                          |
234/// |---------------------------------|---------------------------------------------------------------------------------------------------|-------------------------------------|
235/// | `reactive_graph::core::Action`  | An action can be triggered                                                                        | <ul compact><li>`trigger`</li></ul> |
236/// | `reactive_graph::core::Labeled` | The label is a hierarchical path with static segments, named parameters and catch-all parameters. | <ul compact><li>`label`</li></ul>   |
237///
238/// ### Properties
239///
240/// - delay
241///
242/// ### Properties from components
243///
244/// - label
245/// - trigger
246///
247/// ## JSON Schema
248///
249/// [https://schema.reactive-graph.io/schema/json/dynamic_graph/types/entity/reactive_graph/runtime/Shutdown.schema.json]()
250///
251#[derive(
252    Debug,
253    Clone,
254    PartialEq,
255    Eq,
256    serde::Serialize,
257    serde::Deserialize,
258    typed_builder::TypedBuilder
259)]
260pub struct Shutdown {
261    #[builder(default, setter(into))]
262    pub id: uuid::Uuid,
263    
264    /// ### Property `delay`
265    ///
266    /// Data Type: `Number`
267    ///
268    /// Socket Type: `None`
269    ///
270    /// Mutability: `Mutable`
271    ///
272    pub delay: u64,
273    
274    /// ### Property `label`
275    ///
276    /// Hierarchical path with static segments, named parameters and catch-all parameters
277    ///
278    /// Data Type: `String`
279    ///
280    /// Socket Type: `None`
281    ///
282    /// Mutability: `Mutable`
283    ///
284    #[builder(setter(into))]
285    pub label: String,
286    
287    /// ### Property `trigger`
288    ///
289    /// On receiving a boolean trigger the action will be executed
290    ///
291    /// Data Type: `Bool`
292    ///
293    /// Socket Type: `Input`
294    ///
295    /// Mutability: `Mutable`
296    ///
297    pub trigger: bool,
298    #[builder(default, setter(into))]
299    pub extensions: reactive_graph_graph::Extensions,
300}
301
302impl Shutdown {
303    pub fn new(delay: u64, label: String, trigger: bool) -> Self {
304        Self {
305            id: uuid::Uuid::new_v4(),
306            delay,
307            label,
308            trigger,
309            extensions: reactive_graph_graph::Extensions::new(),
310        }
311    }
312    pub fn new_with_id(
313        id: uuid::Uuid,
314        delay: u64,
315        label: String,
316        trigger: bool,
317    ) -> Self {
318        Self {
319            id,
320            delay,
321            label,
322            trigger,
323            extensions: reactive_graph_graph::Extensions::new(),
324        }
325    }
326    pub fn new_with_extensions(
327        id: uuid::Uuid,
328        delay: u64,
329        label: String,
330        trigger: bool,
331        extensions: reactive_graph_graph::Extensions,
332    ) -> Self {
333        Self {
334            id,
335            delay,
336            label,
337            trigger,
338            extensions,
339        }
340    }
341    
342    pub fn id(&self) -> uuid::Uuid {
343        self.id
344    }
345    
346    /// ### Property `delay`
347    ///
348    /// Data Type: `Number`
349    ///
350    /// Socket Type: `None`
351    ///
352    /// Mutability: `Mutable`
353    ///
354    pub fn delay(&self) -> u64 {
355        self.delay
356    }
357    
358    /// ### Property `delay`
359    ///
360    /// Data Type: `Number`
361    ///
362    /// Socket Type: `None`
363    ///
364    /// Mutability: `Mutable`
365    ///
366    pub fn set_delay(&mut self, delay: u64) {
367        self.delay = delay;
368    }
369    
370    /// ### Property `label`
371    ///
372    /// Hierarchical path with static segments, named parameters and catch-all parameters
373    ///
374    /// Data Type: `String`
375    ///
376    /// Socket Type: `None`
377    ///
378    /// Mutability: `Mutable`
379    ///
380    pub fn label(&self) -> String {
381        self.label.clone()
382    }
383    
384    /// ### Property `label`
385    ///
386    /// Hierarchical path with static segments, named parameters and catch-all parameters
387    ///
388    /// Data Type: `String`
389    ///
390    /// Socket Type: `None`
391    ///
392    /// Mutability: `Mutable`
393    ///
394    pub fn set_label(&mut self, label: String) {
395        self.label = label;
396    }
397    
398    /// ### Property `trigger`
399    ///
400    /// On receiving a boolean trigger the action will be executed
401    ///
402    /// Data Type: `Bool`
403    ///
404    /// Socket Type: `Input`
405    ///
406    /// Mutability: `Mutable`
407    ///
408    pub fn trigger(&self) -> bool {
409        self.trigger
410    }
411    
412    /// ### Property `trigger`
413    ///
414    /// On receiving a boolean trigger the action will be executed
415    ///
416    /// Data Type: `Bool`
417    ///
418    /// Socket Type: `Input`
419    ///
420    /// Mutability: `Mutable`
421    ///
422    pub fn set_trigger(&mut self, trigger: bool) {
423        self.trigger = trigger;
424    }
425    
426    pub fn properties(&self) -> reactive_graph_graph::PropertyInstances {
427        reactive_graph_graph::PropertyInstances::new()
428            .property(ShutdownProperties::DELAY, self.delay.clone())
429            .property(ShutdownProperties::LABEL, self.label.clone())
430            .property(ShutdownProperties::TRIGGER, self.trigger.clone())
431    }
432    
433    pub fn extensions(&self) -> reactive_graph_graph::Extensions {
434        self.extensions.clone()
435    }
436}
437
438impl From<Shutdown> for reactive_graph_graph::EntityInstance {
439    fn from(shutdown: Shutdown) -> Self {
440        reactive_graph_graph::EntityInstance::builder()
441            .ty(std::ops::Deref::deref(&SHUTDOWN))
442            .id(shutdown.id())
443            .components(SHUTDOWN_COMPONENTS.clone())
444            .properties(shutdown.properties())
445            .build()
446    }
447}
448
449impl TryFrom<reactive_graph_graph::EntityInstance> for Shutdown {
450    type Error = ();
451    fn try_from(
452        entity_instance: reactive_graph_graph::EntityInstance,
453    ) -> Result<Self, Self::Error> {
454        Err(())
455    }
456}
457impl reactive_graph_model_core::reactive_graph::core::action::Action for Shutdown {
458    
459    /// ### Property `trigger`
460    ///
461    /// On receiving a boolean trigger the action will be executed
462    ///
463    /// Data Type: `Bool`
464    ///
465    /// Socket Type: `Input`
466    ///
467    /// Mutability: `Mutable`
468    ///
469    fn trigger(&self) -> bool {
470        self.trigger
471    }
472    
473    /// ### Property `trigger`
474    ///
475    /// On receiving a boolean trigger the action will be executed
476    ///
477    /// Data Type: `Bool`
478    ///
479    /// Socket Type: `Input`
480    ///
481    /// Mutability: `Mutable`
482    ///
483    fn set_trigger(&mut self, trigger: bool) {
484        self.trigger = trigger;
485    }
486}
487impl reactive_graph_model_core::reactive_graph::core::labeled::Labeled for Shutdown {
488    
489    /// ### Property `label`
490    ///
491    /// Hierarchical path with static segments, named parameters and catch-all parameters
492    ///
493    /// Data Type: `String`
494    ///
495    /// Socket Type: `None`
496    ///
497    /// Mutability: `Mutable`
498    ///
499    fn label(&self) -> String {
500        self.label.clone()
501    }
502    
503    /// ### Property `label`
504    ///
505    /// Hierarchical path with static segments, named parameters and catch-all parameters
506    ///
507    /// Data Type: `String`
508    ///
509    /// Socket Type: `None`
510    ///
511    /// Mutability: `Mutable`
512    ///
513    fn set_label(&mut self, label: String) {
514        self.label = label;
515    }
516}