charming_fork_zephyr/element/
dimension_encode.rs1use serde::Serialize;
2
3use crate::datatype::CompositeValue;
4
5#[derive(Serialize)]
6#[serde(rename_all = "camelCase")]
7pub struct DimensionEncode {
8 #[serde(skip_serializing_if = "Option::is_none")]
9 x: Option<CompositeValue>,
10
11 #[serde(skip_serializing_if = "Option::is_none")]
12 y: Option<CompositeValue>,
13
14 #[serde(skip_serializing_if = "Option::is_none")]
15 z: Option<CompositeValue>,
16
17 #[serde(skip_serializing_if = "Option::is_none")]
18 item_name: Option<String>,
19
20 #[serde(skip_serializing_if = "Vec::is_empty")]
21 tooltip: Vec<CompositeValue>,
22}
23
24impl DimensionEncode {
25 pub fn new() -> Self {
26 Self {
27 x: None,
28 y: None,
29 z: None,
30 item_name: None,
31 tooltip: vec![],
32 }
33 }
34
35 pub fn x<C: Into<CompositeValue>>(mut self, x: C) -> Self {
36 self.x = Some(x.into());
37 self
38 }
39
40 pub fn y<C: Into<CompositeValue>>(mut self, y: C) -> Self {
41 self.y = Some(y.into());
42 self
43 }
44
45 pub fn z<C: Into<CompositeValue>>(mut self, z: C) -> Self {
46 self.z = Some(z.into());
47 self
48 }
49
50 pub fn item_name<S: Into<String>>(mut self, item_name: S) -> Self {
51 self.item_name = Some(item_name.into());
52 self
53 }
54
55 pub fn tooltip<S: Into<CompositeValue>>(mut self, tooltip: Vec<S>) -> Self {
56 self.tooltip = tooltip.into_iter().map(|s| s.into()).collect();
57 self
58 }
59}