docx_rs/documents/
custom_item_property.rs1use serde::Serialize;
2use std::io::Write;
3
4use crate::documents::BuildXML;
5use crate::xml_builder::*;
6
7#[derive(Debug, Clone, Serialize)]
8pub struct CustomItemProperty {
9 id: String,
10}
11
12impl CustomItemProperty {
13 pub fn new(id: impl Into<String>) -> Self {
14 Self { id: id.into() }
15 }
16}
17
18impl BuildXML for CustomItemProperty {
19 fn build_to<W: Write>(
20 &self,
21 stream: xml::writer::EventWriter<W>,
22 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
23 XMLBuilder::from(stream)
24 .declaration(Some(false))?
25 .open_data_store_item(
26 "http://schemas.openxmlformats.org/officeDocument/2006/customXml",
27 &format!("{{{}}}", self.id),
28 )?
29 .open_data_store_schema_refs()?
30 .close()?
31 .close()?
32 .into_inner()
33 }
34}