reactive_graph_command_model/reactive_graph/command/
command.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::command::Command`
8#[cfg_attr(rustfmt, rustfmt_skip)]
9pub const COMMAND_NAMESPACE: &str = "reactive_graph::command::Command";
10
11/// The [type identifier]() of Component `Command`.
12///
13/// ### Namespace
14///
15/// The fully qualified namespace is
16/// `reactive_graph::command::Command`
17pub static COMMAND: std::sync::LazyLock<reactive_graph_graph::ComponentTypeId> = std::sync::LazyLock::new(||
18std::str::FromStr::from_str(COMMAND_NAMESPACE).unwrap());
19
20/// The properties of Component `Command`.
21#[allow(non_camel_case_types)]
22#[derive(Debug, PartialEq, PartialOrd, Eq, Hash, Clone)]
23pub enum CommandProperties {
24    
25    /// ### Property `args`
26    ///
27    /// The command arguments
28    ///
29    /// Data Type: `Array`
30    ///
31    /// Socket Type: `None`
32    ///
33    /// Mutability: `Immutable`
34    ///
35    ARGS,
36    
37    /// ### Property `cmd_ignore`
38    ///
39    /// blah
40    ///
41    /// Data Type: `Any`
42    ///
43    /// Socket Type: `None`
44    ///
45    /// Mutability: `Mutable`
46    ///
47    CMD_IGNORE,
48    
49    /// ### Property `cmd_result`
50    ///
51    /// The result of the command
52    ///
53    /// Data Type: `Any`
54    ///
55    /// Socket Type: `Output`
56    ///
57    /// Mutability: `Immutable`
58    ///
59    CMD_RESULT,
60    
61    /// ### Property `command`
62    ///
63    /// The command name
64    ///
65    /// Data Type: `String`
66    ///
67    /// Socket Type: `None`
68    ///
69    /// Mutability: `Immutable`
70    ///
71    COMMAND,
72    
73    /// ### Property `help`
74    ///
75    /// Help text which explains the command.
76    ///
77    /// Data Type: `String`
78    ///
79    /// Socket Type: `None`
80    ///
81    /// Mutability: `Immutable`
82    ///
83    HELP,
84    
85    /// ### Property `namespace`
86    ///
87    /// The command namespace
88    ///
89    /// Data Type: `String`
90    ///
91    /// Socket Type: `None`
92    ///
93    /// Mutability: `Immutable`
94    ///
95    NAMESPACE,
96}
97impl CommandProperties {
98    pub fn len() -> usize {
99        6usize
100    }
101    
102    pub fn property_types() -> reactive_graph_graph::PropertyTypes {
103        let property_types = reactive_graph_graph::PropertyTypes::new();
104        property_types.push(CommandProperties::ARGS);
105        property_types.push(CommandProperties::CMD_IGNORE);
106        property_types.push(CommandProperties::CMD_RESULT);
107        property_types.push(CommandProperties::COMMAND);
108        property_types.push(CommandProperties::HELP);
109        property_types.push(CommandProperties::NAMESPACE);
110        property_types
111    }
112}
113
114impl AsRef<str> for CommandProperties {
115    #[inline]
116    fn as_ref(&self) -> &str {
117        match *self {
118            CommandProperties::ARGS => "args",
119            CommandProperties::CMD_IGNORE => "cmd_ignore",
120            CommandProperties::CMD_RESULT => "cmd_result",
121            CommandProperties::COMMAND => "command",
122            CommandProperties::HELP => "help",
123            CommandProperties::NAMESPACE => "namespace",
124        }
125    }
126}
127
128impl From<CommandProperties> for &'static str {
129    #[inline]
130    fn from(properties: CommandProperties) -> &'static str {
131        match properties {
132            CommandProperties::ARGS => "args",
133            CommandProperties::CMD_IGNORE => "cmd_ignore",
134            CommandProperties::CMD_RESULT => "cmd_result",
135            CommandProperties::COMMAND => "command",
136            CommandProperties::HELP => "help",
137            CommandProperties::NAMESPACE => "namespace",
138        }
139    }
140}
141
142impl From<CommandProperties> for String {
143    #[inline]
144    fn from(properties: CommandProperties) -> String {
145        match properties {
146            CommandProperties::ARGS => "args".to_owned(),
147            CommandProperties::CMD_IGNORE => "cmd_ignore".to_owned(),
148            CommandProperties::CMD_RESULT => "cmd_result".to_owned(),
149            CommandProperties::COMMAND => "command".to_owned(),
150            CommandProperties::HELP => "help".to_owned(),
151            CommandProperties::NAMESPACE => "namespace".to_owned(),
152        }
153    }
154}
155
156impl From<CommandProperties> for reactive_graph_graph::PropertyType {
157    #[inline]
158    fn from(properties: CommandProperties) -> reactive_graph_graph::PropertyType {
159        match properties {
160            CommandProperties::ARGS => {
161                reactive_graph_graph::PropertyType::new_with_all(
162                    "args",
163                    "The command arguments",
164                    reactive_graph_graph::DataType::Array,
165                    reactive_graph_graph::SocketType::None,
166                    reactive_graph_graph::Mutability::Immutable,
167                    reactive_graph_graph::Extensions::new(),
168                )
169            }
170            CommandProperties::CMD_IGNORE => {
171                reactive_graph_graph::PropertyType::new_with_all(
172                    "cmd_ignore",
173                    "blah",
174                    reactive_graph_graph::DataType::Any,
175                    reactive_graph_graph::SocketType::None,
176                    reactive_graph_graph::Mutability::Mutable,
177                    reactive_graph_graph::Extensions::new(),
178                )
179            }
180            CommandProperties::CMD_RESULT => {
181                reactive_graph_graph::PropertyType::new_with_all(
182                    "cmd_result",
183                    "The result of the command",
184                    reactive_graph_graph::DataType::Any,
185                    reactive_graph_graph::SocketType::Output,
186                    reactive_graph_graph::Mutability::Immutable,
187                    reactive_graph_graph::Extensions::new(),
188                )
189            }
190            CommandProperties::COMMAND => {
191                reactive_graph_graph::PropertyType::new_with_all(
192                    "command",
193                    "The command name",
194                    reactive_graph_graph::DataType::String,
195                    reactive_graph_graph::SocketType::None,
196                    reactive_graph_graph::Mutability::Immutable,
197                    reactive_graph_graph::Extensions::new(),
198                )
199            }
200            CommandProperties::HELP => {
201                reactive_graph_graph::PropertyType::new_with_all(
202                    "help",
203                    "Help text which explains the command.",
204                    reactive_graph_graph::DataType::String,
205                    reactive_graph_graph::SocketType::None,
206                    reactive_graph_graph::Mutability::Immutable,
207                    reactive_graph_graph::Extensions::new(),
208                )
209            }
210            CommandProperties::NAMESPACE => {
211                reactive_graph_graph::PropertyType::new_with_all(
212                    "namespace",
213                    "The command namespace",
214                    reactive_graph_graph::DataType::String,
215                    reactive_graph_graph::SocketType::None,
216                    reactive_graph_graph::Mutability::Immutable,
217                    reactive_graph_graph::Extensions::new(),
218                )
219            }
220        }
221    }
222}
223
224pub struct CommandPropertiesIterator(Option<CommandProperties>);
225
226impl CommandProperties {
227    pub fn into_iter() -> CommandPropertiesIterator {
228        CommandPropertiesIterator(None)
229    }
230}
231
232impl Iterator for CommandPropertiesIterator {
233    type Item = CommandProperties;
234    fn next(&mut self) -> Option<Self::Item> {
235        self.0 = match self.0 {
236            None => Some(CommandProperties::ARGS),
237            Some(CommandProperties::ARGS) => Some(CommandProperties::CMD_IGNORE),
238            Some(CommandProperties::CMD_IGNORE) => Some(CommandProperties::CMD_RESULT),
239            Some(CommandProperties::CMD_RESULT) => Some(CommandProperties::COMMAND),
240            Some(CommandProperties::COMMAND) => Some(CommandProperties::HELP),
241            Some(CommandProperties::HELP) => Some(CommandProperties::NAMESPACE),
242            Some(CommandProperties::NAMESPACE) => None,
243        };
244        self.0.clone()
245    }
246}
247
248impl IntoIterator for CommandProperties {
249    type Item = CommandProperties;
250    type IntoIter = CommandPropertiesIterator;
251    fn into_iter(self) -> Self::IntoIter {
252        CommandPropertiesIterator(None)
253    }
254}
255
256impl core::fmt::Display for CommandProperties {
257    fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
258        match *self {
259            CommandProperties::ARGS => core::fmt::Display::fmt("args", f),
260            CommandProperties::CMD_IGNORE => core::fmt::Display::fmt("cmd_ignore", f),
261            CommandProperties::CMD_RESULT => core::fmt::Display::fmt("cmd_result", f),
262            CommandProperties::COMMAND => core::fmt::Display::fmt("command", f),
263            CommandProperties::HELP => core::fmt::Display::fmt("help", f),
264            CommandProperties::NAMESPACE => core::fmt::Display::fmt("namespace", f),
265        }
266    }
267}
268
269///
270pub static COMMAND_EXTENSIONS: std::sync::LazyLock<reactive_graph_graph::Extensions> = std::sync::LazyLock::new(||
271{ reactive_graph_graph::Extensions::new() });
272
273pub static COMMAND_TYPE: std::sync::LazyLock<reactive_graph_graph::Component> = std::sync::LazyLock::new(||
274{
275    reactive_graph_graph::Component::builder()
276        .ty(core::ops::Deref::deref(&COMMAND))
277        .description(
278            "A command which can be executed. The command has a name and can have command arguments.",
279        )
280        .properties(CommandProperties::property_types())
281        .build()
282});
283
284/// # Component `Command`
285///
286/// ## Fully Qualified Namespace
287///
288/// `reactive_graph::command::Command`
289///
290/// ## Description
291///
292/// A command which can be executed. The command has a name and can have command arguments.
293///
294/// ### Properties
295///
296/// - args
297/// - cmd_ignore
298/// - cmd_result
299/// - command
300/// - help
301/// - namespace
302///
303/// ## JSON Schema
304///
305/// [https://schema.reactive-graph.io/schema/json/dynamic_graph/types/component/reactive_graph/command/Command.schema.json]()
306///
307pub trait Command {
308    
309    /// ### Property `args`
310    ///
311    /// The command arguments
312    ///
313    /// Data Type: `Array`
314    ///
315    /// Socket Type: `None`
316    ///
317    /// Mutability: `Immutable`
318    ///
319    fn args(&self) -> Vec<serde_json::Value>;
320    
321    /// ### Property `cmd_ignore`
322    ///
323    /// blah
324    ///
325    /// Data Type: `Any`
326    ///
327    /// Socket Type: `None`
328    ///
329    /// Mutability: `Mutable`
330    ///
331    fn cmd_ignore(&self) -> serde_json::Value;
332    
333    /// ### Property `cmd_ignore`
334    ///
335    /// blah
336    ///
337    /// Data Type: `Any`
338    ///
339    /// Socket Type: `None`
340    ///
341    /// Mutability: `Mutable`
342    ///
343    fn set_cmd_ignore(&mut self, cmd_ignore: serde_json::Value);
344    
345    /// ### Property `cmd_result`
346    ///
347    /// The result of the command
348    ///
349    /// Data Type: `Any`
350    ///
351    /// Socket Type: `Output`
352    ///
353    /// Mutability: `Immutable`
354    ///
355    fn cmd_result(&self) -> serde_json::Value;
356    
357    /// ### Property `command`
358    ///
359    /// The command name
360    ///
361    /// Data Type: `String`
362    ///
363    /// Socket Type: `None`
364    ///
365    /// Mutability: `Immutable`
366    ///
367    fn command(&self) -> String;
368    
369    /// ### Property `help`
370    ///
371    /// Help text which explains the command.
372    ///
373    /// Data Type: `String`
374    ///
375    /// Socket Type: `None`
376    ///
377    /// Mutability: `Immutable`
378    ///
379    fn help(&self) -> String;
380    
381    /// ### Property `namespace`
382    ///
383    /// The command namespace
384    ///
385    /// Data Type: `String`
386    ///
387    /// Socket Type: `None`
388    ///
389    /// Mutability: `Immutable`
390    ///
391    fn namespace(&self) -> String;
392}