docx_rs/documents/
comments_extended.rs1use serde::Serialize;
2use std::io::Write;
3
4use super::*;
5use crate::documents::BuildXML;
6use crate::xml_builder::*;
7
8#[derive(Debug, Clone, PartialEq, Serialize, Default)]
10#[serde(rename_all = "camelCase")]
11pub struct CommentsExtended {
12 pub children: Vec<CommentExtended>,
13}
14
15impl CommentsExtended {
16 pub fn new() -> CommentsExtended {
17 Default::default()
18 }
19
20 pub fn add_comments_extended(&mut self, c: Vec<CommentExtended>) {
21 self.children = c;
22 }
23}
24
25impl BuildXML for CommentsExtended {
26 fn build_to<W: Write>(
27 &self,
28 stream: xml::writer::EventWriter<W>,
29 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
30 XMLBuilder::from(stream)
31 .open_comments_extended()?
32 .add_children(&self.children)?
33 .close()?
34 .into_inner()
35 }
36}
37
38#[cfg(test)]
39mod tests {
40
41 use super::*;
42 use insta::assert_snapshot;
43 use std::str;
44
45 #[test]
46 fn test_settings() {
47 let mut c = CommentsExtended::new();
48 c.add_comments_extended(vec![CommentExtended::new("123")]);
49 let b = c.build();
50 assert_snapshot!("comments_extended_snapshot", str::from_utf8(&b).unwrap());
51 }
52}