docx_rs/documents/elements/
table_layout.rs1use serde::{Serialize, Serializer};
2use std::io::Write;
3
4use crate::documents::BuildXML;
5use crate::types::*;
6use crate::xml_builder::*;
7
8#[derive(Debug, Clone, PartialEq)]
9pub struct TableLayout {
10 layout_type: TableLayoutType,
11}
12
13impl TableLayout {
14 pub fn new(t: TableLayoutType) -> TableLayout {
15 TableLayout { layout_type: t }
16 }
17}
18
19impl BuildXML for TableLayout {
20 fn build_to<W: Write>(
21 &self,
22 stream: xml::writer::EventWriter<W>,
23 ) -> xml::writer::Result<xml::writer::EventWriter<W>> {
24 XMLBuilder::from(stream)
25 .table_layout(&self.layout_type.to_string())?
26 .into_inner()
27 }
28}
29
30impl Serialize for TableLayout {
31 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
32 where
33 S: Serializer,
34 {
35 serializer.serialize_str(&self.layout_type.to_string())
36 }
37}