lirays/models.rs
1/// Configuration used to create an integer variable in the namespace.
2///
3/// # Example
4/// ```rust
5/// use lirays::IntegerVar;
6///
7/// let var = IntegerVar {
8/// name: "motor_rpm".into(),
9/// unit: Some("rpm".into()),
10/// min: Some(0.0),
11/// max: Some(3600.0),
12/// };
13/// assert_eq!(var.name, "motor_rpm");
14/// ```
15#[derive(Clone, Debug)]
16pub struct IntegerVar {
17 /// Variable name relative to its parent folder.
18 pub name: String,
19 /// Optional engineering unit (for example, `rpm` or `bar`).
20 pub unit: Option<String>,
21 /// Optional minimum allowed value.
22 pub min: Option<f64>,
23 /// Optional maximum allowed value.
24 pub max: Option<f64>,
25}
26
27/// Configuration used to create a float variable in the namespace.
28///
29/// # Example
30/// ```rust
31/// use lirays::FloatVar;
32///
33/// let var = FloatVar {
34/// name: "tank_level".into(),
35/// unit: Some("%".into()),
36/// min: Some(0.0),
37/// max: Some(100.0),
38/// };
39/// assert_eq!(var.unit.as_deref(), Some("%"));
40/// ```
41#[derive(Clone, Debug)]
42pub struct FloatVar {
43 /// Variable name relative to its parent folder.
44 pub name: String,
45 /// Optional engineering unit (for example, `rpm` or `bar`).
46 pub unit: Option<String>,
47 /// Optional minimum allowed value.
48 pub min: Option<f64>,
49 /// Optional maximum allowed value.
50 pub max: Option<f64>,
51}
52
53/// Configuration used to create a text variable in the namespace.
54///
55/// # Example
56/// ```rust
57/// use lirays::TextVar;
58///
59/// let var = TextVar {
60/// name: "mode".into(),
61/// unit: None,
62/// options: vec!["AUTO".into(), "MAN".into(), "OFF".into()],
63/// max_len: Some(8),
64/// };
65/// assert_eq!(var.options.len(), 3);
66/// ```
67#[derive(Clone, Debug)]
68pub struct TextVar {
69 /// Variable name relative to its parent folder.
70 pub name: String,
71 /// Optional engineering unit or semantic label.
72 pub unit: Option<String>,
73 /// Optional list of allowed values.
74 pub options: Vec<String>,
75 /// Optional maximum character length.
76 pub max_len: Option<u64>,
77}
78
79/// Configuration used to create a boolean variable in the namespace.
80///
81/// # Example
82/// ```rust
83/// use lirays::BooleanVar;
84///
85/// let var = BooleanVar {
86/// name: "pump_enabled".into(),
87/// unit: None,
88/// };
89/// assert_eq!(var.name, "pump_enabled");
90/// ```
91#[derive(Clone, Debug)]
92pub struct BooleanVar {
93 /// Variable name relative to its parent folder.
94 pub name: String,
95 /// Optional engineering unit or semantic label.
96 pub unit: Option<String>,
97}
98
99/// Partial metadata update payload for an existing variable.
100///
101/// # Example
102/// ```rust
103/// use lirays::VariableMetadataPatch;
104///
105/// let patch = VariableMetadataPatch {
106/// unit: Some("psi".into()),
107/// min: Some(1.0),
108/// max: Some(20.0),
109/// options: vec![],
110/// max_len: None,
111/// };
112/// assert_eq!(patch.unit.as_deref(), Some("psi"));
113/// ```
114#[derive(Clone, Debug, Default)]
115pub struct VariableMetadataPatch {
116 /// New engineering unit. `None` keeps current server value.
117 pub unit: Option<String>,
118 /// New minimum value. `None` keeps current server value.
119 pub min: Option<f64>,
120 /// New maximum value. `None` keeps current server value.
121 pub max: Option<f64>,
122 /// New list of allowed text values.
123 pub options: Vec<String>,
124 /// New maximum text length.
125 pub max_len: Option<u64>,
126}