docx_rs/documents/elements/
level_restart.rs

1use serde::{Serialize, Serializer};
2use std::io::Write;
3
4use crate::documents::BuildXML;
5use crate::xml_builder::*;
6
7#[derive(Debug, Clone, PartialEq)]
8pub struct LevelRestart {
9    val: u32,
10}
11
12impl LevelRestart {
13    pub fn new(val: impl Into<u32>) -> Self {
14        Self { val: val.into() }
15    }
16}
17
18impl BuildXML for LevelRestart {
19    fn build_to<W: Write>(
20        &self,
21        stream: xml::writer::EventWriter<W>,
22    ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
23        XMLBuilder::from(stream)
24            .level_restart(&format!("{}", &self.val))?
25            .into_inner()
26    }
27}
28
29impl Serialize for LevelRestart {
30    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
31    where
32        S: Serializer,
33    {
34        serializer.serialize_u32(self.val)
35    }
36}