docx_rs/documents/elements/
tabs.rs

1use serde::{Deserialize, Serialize};
2use std::io::Write;
3
4use crate::documents::BuildXML;
5use crate::xml_builder::*;
6use crate::Tab;
7
8#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Default)]
9pub struct Tabs {
10    pub tabs: Vec<Tab>,
11}
12
13impl Tabs {
14    pub fn new() -> Self {
15        Default::default()
16    }
17
18    pub fn add_tab(mut self, t: Tab) -> Self {
19        self.tabs.push(t);
20        self
21    }
22}
23
24impl BuildXML for Tabs {
25    fn build_to<W: Write>(
26        &self,
27        stream: xml::writer::EventWriter<W>,
28    ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
29        XMLBuilder::from(stream)
30            .apply_each(&self.tabs, |t, b| b.tab(t.val, t.leader, t.pos))?
31            .into_inner()
32    }
33}