docx_rs/documents/elements/
div.rs

1use serde::Serialize;
2
3#[derive(Debug, Clone, PartialEq, Serialize)]
4#[serde(rename_all = "camelCase")]
5pub struct Div {
6    pub id: String,
7    pub margin_left: usize,
8    pub margin_right: usize,
9    pub margin_top: usize,
10    pub margin_bottom: usize,
11    pub divs_child: Vec<Div>,
12}
13
14impl Default for Div {
15    fn default() -> Self {
16        Self {
17            id: "".to_string(),
18            margin_left: 0,
19            margin_right: 0,
20            margin_top: 0,
21            margin_bottom: 0,
22            divs_child: vec![],
23        }
24    }
25}
26
27impl Div {
28    pub fn new(id: impl Into<String>) -> Self {
29        Self {
30            id: id.into(),
31            ..Default::default()
32        }
33    }
34
35    pub fn margin_left(mut self, s: usize) -> Self {
36        self.margin_left = s;
37        self
38    }
39
40    pub fn margin_right(mut self, s: usize) -> Self {
41        self.margin_right = s;
42        self
43    }
44
45    pub fn margin_top(mut self, s: usize) -> Self {
46        self.margin_top = s;
47        self
48    }
49
50    pub fn margin_bottom(mut self, s: usize) -> Self {
51        self.margin_bottom = s;
52        self
53    }
54
55    pub fn add_child(mut self, s: Div) -> Self {
56        self.divs_child.push(s);
57        self
58    }
59}