docx_reader/documents/elements/
div.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use serde::Serialize;

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Div {
	pub id: String,
	pub margin_left: usize,
	pub margin_right: usize,
	pub margin_top: usize,
	pub margin_bottom: usize,
	pub divs_child: Vec<Div>,
}

impl Default for Div {
	fn default() -> Self {
		Self {
			id: "".to_string(),
			margin_left: 0,
			margin_right: 0,
			margin_top: 0,
			margin_bottom: 0,
			divs_child: vec![],
		}
	}
}

impl Div {
	pub fn new(id: impl Into<String>) -> Self {
		Self {
			id: id.into(),
			..Default::default()
		}
	}

	pub fn margin_left(mut self, s: usize) -> Self {
		self.margin_left = s;
		self
	}

	pub fn margin_right(mut self, s: usize) -> Self {
		self.margin_right = s;
		self
	}

	pub fn margin_top(mut self, s: usize) -> Self {
		self.margin_top = s;
		self
	}

	pub fn margin_bottom(mut self, s: usize) -> Self {
		self.margin_bottom = s;
		self
	}

	pub fn add_child(mut self, s: Div) -> Self {
		self.divs_child.push(s);
		self
	}
}