reactive_graph_graph/instances/properties/
property.rs1#[macro_export]
2macro_rules! properties {
3 (
4 $properties: ident
6 $(,
7 (
8 $property_ident: ident,
10
11 $property_name: expr,
13
14 $property_default_value: expr
16 )
17 )*
18 ) => {
19 #[allow(non_camel_case_types)]
20 #[derive(strum_macros::AsRefStr, strum_macros::IntoStaticStr, strum_macros::Display)]
21 pub enum $properties {
22 $(
23 #[strum(serialize = $property_name)]
24 $property_ident,
25 )*
26 }
27
28 impl $crate::PropertyTypeDefinition for $properties {
29 fn property_name(&self) -> String {
30 self.as_ref().into()
31 }
32
33 fn default_value(&self) -> serde_json::Value {
34 match self {
35 $(
36 $properties::$property_ident => serde_json::json!($property_default_value),
37 )*
38 }
39 }
40 }
41
42 impl From<$properties> for String {
43 fn from(p: $properties) -> Self {
44 p.to_string()
45 }
46 }
47 };
48}