Skip to main content

lumen_engine/node/
param_type.rs

1use super::schema::PropertyKind;
2
3#[cfg(any(feature = "json", feature = "metadata"))]
4use super::schema::EnumDef;
5
6pub trait NodeParamType {
7    fn property_kind() -> PropertyKind;
8    #[cfg(any(feature = "json", feature = "metadata"))]
9    fn enum_def() -> Option<&'static EnumDef> {
10        None
11    }
12}
13
14impl NodeParamType for f64 {
15    fn property_kind() -> PropertyKind {
16        PropertyKind::Float
17    }
18}
19
20impl NodeParamType for f32 {
21    fn property_kind() -> PropertyKind {
22        PropertyKind::Float
23    }
24}
25
26impl NodeParamType for u8 {
27    fn property_kind() -> PropertyKind {
28        PropertyKind::Int
29    }
30}
31
32impl NodeParamType for u32 {
33    fn property_kind() -> PropertyKind {
34        PropertyKind::Int
35    }
36}
37
38impl NodeParamType for i64 {
39    fn property_kind() -> PropertyKind {
40        PropertyKind::Int
41    }
42}
43
44impl NodeParamType for bool {
45    fn property_kind() -> PropertyKind {
46        PropertyKind::Bool
47    }
48}
49
50impl NodeParamType for String {
51    fn property_kind() -> PropertyKind {
52        PropertyKind::String
53    }
54}
55
56impl NodeParamType for [u8; 4] {
57    fn property_kind() -> PropertyKind {
58        PropertyKind::Color
59    }
60}
61
62impl NodeParamType for (f64, f64) {
63    fn property_kind() -> PropertyKind {
64        PropertyKind::Vec2
65    }
66}
67
68impl NodeParamType for [f32; 2] {
69    fn property_kind() -> PropertyKind {
70        PropertyKind::Vec2
71    }
72}
73
74impl<T> NodeParamType for Vec<T> {
75    fn property_kind() -> PropertyKind {
76        PropertyKind::String
77    }
78}