docx_rs/documents/elements/
vanish.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, Default)]
8pub struct Vanish {}
9
10impl Vanish {
11 pub fn new() -> Vanish {
12 Vanish {}
13 }
14}
15
16impl BuildXML for Vanish {
17 fn build_to<W: Write>(
18 &self,
19 stream: xml::writer::EventWriter<W>,
20 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
21 XMLBuilder::from(stream).vanish()?.into_inner()
22 }
23}
24
25impl Serialize for Vanish {
26 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
27 where
28 S: Serializer,
29 {
30 serializer.serialize_bool(true)
31 }
32}
33
34#[cfg(test)]
35mod tests {
36
37 use super::*;
38 #[cfg(test)]
39 use pretty_assertions::assert_eq;
40 use std::str;
41
42 #[test]
43 fn test_build() {
44 let c = Vanish::new();
45 let b = c.build();
46 assert_eq!(str::from_utf8(&b).unwrap(), r#"<w:vanish />"#);
47 }
48}