docx_rs/documents/elements/
caps.rs1use serde::{Deserialize, Serialize, Serializer};
2use std::io::Write;
3
4use crate::{xml_builder::XMLBuilder, BuildXML};
5
6#[derive(Debug, Clone, Deserialize, PartialEq)]
10pub struct Caps {
11 val: bool,
12}
13
14impl Caps {
15 pub fn new() -> Caps {
16 Default::default()
17 }
18
19 pub fn disable(mut self) -> Caps {
20 self.val = false;
21 self
22 }
23}
24
25impl Default for Caps {
26 fn default() -> Self {
27 Self { val: true }
28 }
29}
30
31impl Serialize for Caps {
32 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
33 where
34 S: Serializer,
35 {
36 serializer.serialize_bool(self.val)
37 }
38}
39
40impl BuildXML for Caps {
41 fn build_to<W: Write>(
42 &self,
43 stream: xml::writer::EventWriter<W>,
44 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
45 XMLBuilder::from(stream)
46 .caps(&self.val.to_string())?
47 .into_inner()
48 }
49}