reactive_graph_command_model/reactive_graph/command/
num_commands.rs1#![allow(dead_code, unused)]
5#![cfg_attr(rustfmt, rustfmt_skip)]
6
7#[cfg_attr(rustfmt, rustfmt_skip)]
9pub const NUM_COMMANDS_NAMESPACE: &str = "reactive_graph::command::NumCommands";
10
11pub static NUM_COMMANDS: std::sync::LazyLock<reactive_graph_graph::EntityTypeId> = std::sync::LazyLock::new(||
18std::str::FromStr::from_str(NUM_COMMANDS_NAMESPACE).unwrap());
19
20#[allow(non_camel_case_types)]
22#[derive(Debug, PartialEq, PartialOrd, Eq, Hash, Clone)]
23pub enum NumCommandsProperties {
24
25 ARGS,
36
37 CMD_IGNORE,
48
49 CMD_RESULT,
60
61 COMMAND,
72
73 HELP,
84
85 NAMESPACE,
96}
97impl NumCommandsProperties {
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(NumCommandsProperties::ARGS);
105 property_types.push(NumCommandsProperties::CMD_IGNORE);
106 property_types.push(NumCommandsProperties::CMD_RESULT);
107 property_types.push(NumCommandsProperties::COMMAND);
108 property_types.push(NumCommandsProperties::HELP);
109 property_types.push(NumCommandsProperties::NAMESPACE);
110 property_types
111 }
112}
113
114impl AsRef<str> for NumCommandsProperties {
115 #[inline]
116 fn as_ref(&self) -> &str {
117 match *self {
118 NumCommandsProperties::ARGS => "args",
119 NumCommandsProperties::CMD_IGNORE => "cmd_ignore",
120 NumCommandsProperties::CMD_RESULT => "cmd_result",
121 NumCommandsProperties::COMMAND => "command",
122 NumCommandsProperties::HELP => "help",
123 NumCommandsProperties::NAMESPACE => "namespace",
124 }
125 }
126}
127
128impl From<NumCommandsProperties> for &'static str {
129 #[inline]
130 fn from(properties: NumCommandsProperties) -> &'static str {
131 match properties {
132 NumCommandsProperties::ARGS => "args",
133 NumCommandsProperties::CMD_IGNORE => "cmd_ignore",
134 NumCommandsProperties::CMD_RESULT => "cmd_result",
135 NumCommandsProperties::COMMAND => "command",
136 NumCommandsProperties::HELP => "help",
137 NumCommandsProperties::NAMESPACE => "namespace",
138 }
139 }
140}
141
142impl From<NumCommandsProperties> for String {
143 #[inline]
144 fn from(properties: NumCommandsProperties) -> String {
145 match properties {
146 NumCommandsProperties::ARGS => "args".to_owned(),
147 NumCommandsProperties::CMD_IGNORE => "cmd_ignore".to_owned(),
148 NumCommandsProperties::CMD_RESULT => "cmd_result".to_owned(),
149 NumCommandsProperties::COMMAND => "command".to_owned(),
150 NumCommandsProperties::HELP => "help".to_owned(),
151 NumCommandsProperties::NAMESPACE => "namespace".to_owned(),
152 }
153 }
154}
155
156impl From<NumCommandsProperties> for reactive_graph_graph::PropertyType {
157 #[inline]
158 fn from(properties: NumCommandsProperties) -> reactive_graph_graph::PropertyType {
159 match properties {
160 NumCommandsProperties::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 NumCommandsProperties::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 NumCommandsProperties::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 NumCommandsProperties::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 NumCommandsProperties::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 NumCommandsProperties::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 NumCommandsPropertiesIterator(Option<NumCommandsProperties>);
225
226impl NumCommandsProperties {
227 pub fn into_iter() -> NumCommandsPropertiesIterator {
228 NumCommandsPropertiesIterator(None)
229 }
230}
231
232impl Iterator for NumCommandsPropertiesIterator {
233 type Item = NumCommandsProperties;
234 fn next(&mut self) -> Option<Self::Item> {
235 self.0 = match self.0 {
236 None => Some(NumCommandsProperties::ARGS),
237 Some(NumCommandsProperties::ARGS) => Some(NumCommandsProperties::CMD_IGNORE),
238 Some(NumCommandsProperties::CMD_IGNORE) => {
239 Some(NumCommandsProperties::CMD_RESULT)
240 }
241 Some(NumCommandsProperties::CMD_RESULT) => {
242 Some(NumCommandsProperties::COMMAND)
243 }
244 Some(NumCommandsProperties::COMMAND) => Some(NumCommandsProperties::HELP),
245 Some(NumCommandsProperties::HELP) => Some(NumCommandsProperties::NAMESPACE),
246 Some(NumCommandsProperties::NAMESPACE) => None,
247 };
248 self.0.clone()
249 }
250}
251
252impl IntoIterator for NumCommandsProperties {
253 type Item = NumCommandsProperties;
254 type IntoIter = NumCommandsPropertiesIterator;
255 fn into_iter(self) -> Self::IntoIter {
256 NumCommandsPropertiesIterator(None)
257 }
258}
259
260impl core::fmt::Display for NumCommandsProperties {
261 fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
262 match *self {
263 NumCommandsProperties::ARGS => core::fmt::Display::fmt("args", f),
264 NumCommandsProperties::CMD_IGNORE => core::fmt::Display::fmt("cmd_ignore", f),
265 NumCommandsProperties::CMD_RESULT => core::fmt::Display::fmt("cmd_result", f),
266 NumCommandsProperties::COMMAND => core::fmt::Display::fmt("command", f),
267 NumCommandsProperties::HELP => core::fmt::Display::fmt("help", f),
268 NumCommandsProperties::NAMESPACE => core::fmt::Display::fmt("namespace", f),
269 }
270 }
271}
272
273pub static NUM_COMMANDS_COMPONENTS: std::sync::LazyLock<
280 reactive_graph_graph::ComponentTypeIds,
281> = std::sync::LazyLock::new(|| {
282 reactive_graph_graph::ComponentTypeIds::new()
283 .component(
284 std::ops::Deref::deref(&crate::reactive_graph::command::command::COMMAND),
285 )
286});
287
288pub static NUM_COMMANDS_EXTENSIONS: std::sync::LazyLock<
290 reactive_graph_graph::Extensions,
291> = std::sync::LazyLock::new(|| { reactive_graph_graph::Extensions::new() });
292
293pub static NUM_COMMANDS_TYPE: std::sync::LazyLock<reactive_graph_graph::EntityType> = std::sync::LazyLock::new(||
294{
295 reactive_graph_graph::EntityType::builder()
296 .ty(core::ops::Deref::deref(&NUM_COMMANDS))
297 .description("The number of commands")
298 .components(NUM_COMMANDS_COMPONENTS.clone())
299 .properties(NumCommandsProperties::property_types())
300 .extensions(NUM_COMMANDS_EXTENSIONS.clone())
301 .build()
302});
303
304#[derive(
334 Debug,
335 Clone,
336 PartialEq,
337 Eq,
338 serde::Serialize,
339 serde::Deserialize,
340 typed_builder::TypedBuilder
341)]
342pub struct NumCommands {
343 #[builder(default, setter(into))]
344 pub id: uuid::Uuid,
345
346 #[builder(setter(into))]
357 pub args: Vec<serde_json::Value>,
358
359 pub cmd_ignore: serde_json::Value,
370
371 pub cmd_result: serde_json::Value,
382
383 #[builder(setter(into))]
394 pub command: String,
395
396 #[builder(setter(into))]
407 pub help: String,
408
409 #[builder(setter(into))]
420 pub namespace: String,
421 #[builder(default, setter(into))]
422 pub extensions: reactive_graph_graph::Extensions,
423}
424
425impl NumCommands {
426 pub fn new(
427 args: Vec<serde_json::Value>,
428 cmd_ignore: serde_json::Value,
429 cmd_result: serde_json::Value,
430 command: String,
431 help: String,
432 namespace: String,
433 ) -> Self {
434 Self {
435 id: uuid::Uuid::new_v4(),
436 args,
437 cmd_ignore,
438 cmd_result,
439 command,
440 help,
441 namespace,
442 extensions: reactive_graph_graph::Extensions::new(),
443 }
444 }
445 pub fn new_with_id(
446 id: uuid::Uuid,
447 args: Vec<serde_json::Value>,
448 cmd_ignore: serde_json::Value,
449 cmd_result: serde_json::Value,
450 command: String,
451 help: String,
452 namespace: String,
453 ) -> Self {
454 Self {
455 id,
456 args,
457 cmd_ignore,
458 cmd_result,
459 command,
460 help,
461 namespace,
462 extensions: reactive_graph_graph::Extensions::new(),
463 }
464 }
465 pub fn new_with_extensions(
466 id: uuid::Uuid,
467 args: Vec<serde_json::Value>,
468 cmd_ignore: serde_json::Value,
469 cmd_result: serde_json::Value,
470 command: String,
471 help: String,
472 namespace: String,
473 extensions: reactive_graph_graph::Extensions,
474 ) -> Self {
475 Self {
476 id,
477 args,
478 cmd_ignore,
479 cmd_result,
480 command,
481 help,
482 namespace,
483 extensions,
484 }
485 }
486
487 pub fn id(&self) -> uuid::Uuid {
488 self.id
489 }
490
491 pub fn args(&self) -> Vec<serde_json::Value> {
502 self.args.clone()
503 }
504
505 pub fn cmd_ignore(&self) -> serde_json::Value {
516 self.cmd_ignore.clone()
517 }
518
519 pub fn set_cmd_ignore(&mut self, cmd_ignore: serde_json::Value) {
530 self.cmd_ignore = cmd_ignore;
531 }
532
533 pub fn cmd_result(&self) -> serde_json::Value {
544 self.cmd_result.clone()
545 }
546
547 pub fn command(&self) -> String {
558 self.command.clone()
559 }
560
561 pub fn help(&self) -> String {
572 self.help.clone()
573 }
574
575 pub fn namespace(&self) -> String {
586 self.namespace.clone()
587 }
588
589 pub fn properties(&self) -> reactive_graph_graph::PropertyInstances {
590 reactive_graph_graph::PropertyInstances::new()
591 .property(NumCommandsProperties::ARGS, self.args.clone())
592 .property(NumCommandsProperties::CMD_IGNORE, self.cmd_ignore.clone())
593 .property(NumCommandsProperties::CMD_RESULT, self.cmd_result.clone())
594 .property(NumCommandsProperties::COMMAND, self.command.clone())
595 .property(NumCommandsProperties::HELP, self.help.clone())
596 .property(NumCommandsProperties::NAMESPACE, self.namespace.clone())
597 }
598
599 pub fn extensions(&self) -> reactive_graph_graph::Extensions {
600 self.extensions.clone()
601 }
602}
603
604impl From<NumCommands> for reactive_graph_graph::EntityInstance {
605 fn from(num_commands: NumCommands) -> Self {
606 reactive_graph_graph::EntityInstance::builder()
607 .ty(std::ops::Deref::deref(&NUM_COMMANDS))
608 .id(num_commands.id())
609 .components(NUM_COMMANDS_COMPONENTS.clone())
610 .properties(num_commands.properties())
611 .build()
612 }
613}
614
615impl TryFrom<reactive_graph_graph::EntityInstance> for NumCommands {
616 type Error = ();
617 fn try_from(
618 entity_instance: reactive_graph_graph::EntityInstance,
619 ) -> Result<Self, Self::Error> {
620 Err(())
621 }
622}
623impl crate::reactive_graph::command::command::Command for NumCommands {
624
625 fn args(&self) -> Vec<serde_json::Value> {
636 self.args.clone()
637 }
638
639 fn cmd_ignore(&self) -> serde_json::Value {
650 self.cmd_ignore.clone()
651 }
652
653 fn set_cmd_ignore(&mut self, cmd_ignore: serde_json::Value) {
664 self.cmd_ignore = cmd_ignore;
665 }
666
667 fn cmd_result(&self) -> serde_json::Value {
678 self.cmd_result.clone()
679 }
680
681 fn command(&self) -> String {
692 self.command.clone()
693 }
694
695 fn help(&self) -> String {
706 self.help.clone()
707 }
708
709 fn namespace(&self) -> String {
720 self.namespace.clone()
721 }
722}