docx_reader/documents/elements/
indent.rs1use serde::ser::{SerializeStruct, Serializer};
2use serde::Serialize;
3
4use crate::types::*;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct Indent {
8 pub start: Option<i32>,
9 pub end: Option<i32>,
10 pub special_indent: Option<SpecialIndentType>,
11 pub start_chars: Option<i32>,
12 pub hanging_chars: Option<i32>,
14 pub first_line_chars: Option<i32>,
15}
16
17impl Indent {
18 pub fn new(
19 start: Option<i32>,
20 special_indent: Option<SpecialIndentType>,
21 end: Option<i32>,
22 start_chars: Option<i32>,
23 ) -> Indent {
24 Indent {
25 start,
26 start_chars,
27 end,
28 special_indent,
29 hanging_chars: None,
31 first_line_chars: None,
32 }
33 }
34
35 pub fn end(mut self, end: i32) -> Self {
36 self.end = Some(end);
37 self
38 }
39
40 pub fn hanging_chars(mut self, chars: i32) -> Self {
41 self.hanging_chars = Some(chars);
42 self
43 }
44
45 pub fn first_line_chars(mut self, chars: i32) -> Self {
46 self.first_line_chars = Some(chars);
47 self
48 }
49}
50
51impl Serialize for Indent {
52 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
53 where
54 S: Serializer,
55 {
56 let mut t = serializer.serialize_struct("Indent", 3)?;
57 t.serialize_field("start", &self.start)?;
58 t.serialize_field("startChars", &self.start_chars)?;
59 t.serialize_field("end", &self.end)?;
60 t.serialize_field("specialIndent", &self.special_indent)?;
61 t.serialize_field("hangingChars", &self.hanging_chars)?;
62 t.serialize_field("firstLineChars", &self.first_line_chars)?;
63 t.end()
64 }
65}