docx_rs/documents/doc_props/
app.rs1use serde::Serialize;
2
3use crate::documents::BuildXML;
4use crate::xml_builder::*;
5
6#[derive(Debug, Clone, PartialEq, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct AppProps {}
9
10impl AppProps {
11 pub fn new() -> AppProps {
12 Default::default()
13 }
14}
15
16impl Default for AppProps {
17 fn default() -> Self {
18 Self {}
19 }
20}
21
22impl BuildXML for AppProps {
23 fn build(&self) -> Vec<u8> {
24 let b = XMLBuilder::new();
25 let base = b.declaration(Some(true)).open_properties(
26 "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
27 "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
28 );
29 base.close().build()
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"?>
48<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes" />"#
49 );
50 }
51}