reactive_graph_model_meta/reactive_graph/meta/
describable.rs1#![allow(dead_code, unused)]
5#![cfg_attr(rustfmt, rustfmt_skip)]
6
7#[cfg_attr(rustfmt, rustfmt_skip)]
9pub const DESCRIBABLE_NAMESPACE: &str = "reactive_graph::meta::Describable";
10
11pub static DESCRIBABLE: std::sync::LazyLock<reactive_graph_graph::ComponentTypeId> = std::sync::LazyLock::new(||
18std::str::FromStr::from_str(DESCRIBABLE_NAMESPACE).unwrap());
19
20#[allow(non_camel_case_types)]
22#[derive(Debug, PartialEq, PartialOrd, Eq, Hash, Clone)]
23pub enum DescribableProperties {
24
25 DESCRIPTION,
36}
37impl DescribableProperties {
38 pub fn len() -> usize {
39 1usize
40 }
41
42 pub fn property_types() -> reactive_graph_graph::PropertyTypes {
43 let property_types = reactive_graph_graph::PropertyTypes::new();
44 property_types.push(DescribableProperties::DESCRIPTION);
45 property_types
46 }
47}
48
49impl AsRef<str> for DescribableProperties {
50 #[inline]
51 fn as_ref(&self) -> &str {
52 match *self {
53 DescribableProperties::DESCRIPTION => "description",
54 }
55 }
56}
57
58impl From<DescribableProperties> for &'static str {
59 #[inline]
60 fn from(properties: DescribableProperties) -> &'static str {
61 match properties {
62 DescribableProperties::DESCRIPTION => "description",
63 }
64 }
65}
66
67impl From<DescribableProperties> for String {
68 #[inline]
69 fn from(properties: DescribableProperties) -> String {
70 match properties {
71 DescribableProperties::DESCRIPTION => "description".to_owned(),
72 }
73 }
74}
75
76impl From<DescribableProperties> for reactive_graph_graph::PropertyType {
77 #[inline]
78 fn from(properties: DescribableProperties) -> reactive_graph_graph::PropertyType {
79 match properties {
80 DescribableProperties::DESCRIPTION => {
81 reactive_graph_graph::PropertyType::new_with_all(
82 "description",
83 "The description of an entity or a relation",
84 reactive_graph_graph::DataType::String,
85 reactive_graph_graph::SocketType::None,
86 reactive_graph_graph::Mutability::Mutable,
87 reactive_graph_graph::Extensions::new(),
88 )
89 }
90 }
91 }
92}
93
94pub struct DescribablePropertiesIterator(Option<DescribableProperties>);
95
96impl DescribableProperties {
97 pub fn into_iter() -> DescribablePropertiesIterator {
98 DescribablePropertiesIterator(None)
99 }
100}
101
102impl Iterator for DescribablePropertiesIterator {
103 type Item = DescribableProperties;
104 fn next(&mut self) -> Option<Self::Item> {
105 self.0 = match self.0 {
106 None => Some(DescribableProperties::DESCRIPTION),
107 Some(DescribableProperties::DESCRIPTION) => None,
108 };
109 self.0.clone()
110 }
111}
112
113impl IntoIterator for DescribableProperties {
114 type Item = DescribableProperties;
115 type IntoIter = DescribablePropertiesIterator;
116 fn into_iter(self) -> Self::IntoIter {
117 DescribablePropertiesIterator(None)
118 }
119}
120
121impl core::fmt::Display for DescribableProperties {
122 fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
123 match *self {
124 DescribableProperties::DESCRIPTION => {
125 core::fmt::Display::fmt("description", f)
126 }
127 }
128 }
129}
130
131pub static DESCRIBABLE_EXTENSIONS: std::sync::LazyLock<
133 reactive_graph_graph::Extensions,
134> = std::sync::LazyLock::new(|| { reactive_graph_graph::Extensions::new() });
135
136pub static DESCRIBABLE_TYPE: std::sync::LazyLock<reactive_graph_graph::Component> = std::sync::LazyLock::new(||
137{
138 reactive_graph_graph::Component::builder()
139 .ty(core::ops::Deref::deref(&DESCRIBABLE))
140 .description("The entity or relation has a description.")
141 .properties(DescribableProperties::property_types())
142 .build()
143});
144
145pub trait Describable {
164
165 fn description(&self) -> String;
176
177 fn set_description(&mut self, description: String);
188}