docx_rs/documents/doc_props/
app.rs1use serde::Serialize;
2use std::io::Write;
3
4use crate::documents::BuildXML;
5use crate::xml_builder::*;
6
7#[derive(Debug, Clone, PartialEq, Serialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct AppProps {}
10
11impl AppProps {
12 pub fn new() -> AppProps {
13 Default::default()
14 }
15}
16
17impl BuildXML for AppProps {
18 fn build_to<W: Write>(
19 &self,
20 stream: xml::writer::EventWriter<W>,
21 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
22 XMLBuilder::from(stream)
23 .declaration(Some(true))?
24 .open_properties(
25 "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
26 "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
27 )?
28 .close()?
29 .into_inner()
30 }
31}
32
33#[cfg(test)]
34mod tests {
35
36 use super::*;
37 #[cfg(test)]
38 use pretty_assertions::assert_eq;
39 use std::str;
40
41 #[test]
42 fn test_default_doc_props_app_build() {
43 let c = AppProps::new();
44 let b = c.build();
45 assert_eq!(
46 str::from_utf8(&b).unwrap(),
47 r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes" />"#
48 );
49 }
50}