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