docx_rs/documents/elements/
tab.rs1use serde::{Deserialize, Serialize};
2use std::io::Write;
3
4use crate::documents::BuildXML;
5use crate::types::*;
6use crate::xml_builder::*;
7
8#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Default)]
9#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
10#[cfg_attr(feature = "wasm", ts(export))]
11pub struct Tab {
12 pub val: Option<TabValueType>,
13 pub leader: Option<TabLeaderType>,
14 pub pos: Option<usize>,
15}
16
17impl Tab {
18 pub fn new() -> Self {
19 Default::default()
20 }
21
22 pub fn val(mut self, v: TabValueType) -> Self {
23 self.val = Some(v);
24 self
25 }
26
27 pub fn leader(mut self, v: TabLeaderType) -> Self {
28 self.leader = Some(v);
29 self
30 }
31
32 pub fn pos(mut self, v: usize) -> Self {
33 self.pos = Some(v);
34 self
35 }
36}
37
38impl BuildXML for Tab {
39 fn build_to<W: Write>(
40 &self,
41 stream: xml::writer::EventWriter<W>,
42 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
43 XMLBuilder::from(stream)
44 .tab(self.val, self.leader, self.pos)?
45 .into_inner()
46 }
47}