docx_rs/documents/elements/
shape.rs

1use serde::Serialize;
2
3#[derive(Serialize, Debug, Clone, PartialEq, Default)]
4#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
5#[cfg_attr(feature = "wasm", ts(export))]
6#[serde(rename_all = "camelCase")]
7pub struct Shape {
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub style: Option<String>,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub image_data: Option<ImageData>,
12}
13// Experimental, For now reader only.
14
15#[derive(Serialize, Debug, Clone, PartialEq, Default)]
16#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
17#[cfg_attr(feature = "wasm", ts(export))]
18#[serde(rename_all = "camelCase")]
19pub struct ImageData {
20    pub id: String,
21}
22
23impl Shape {
24    pub fn new() -> Self {
25        Default::default()
26    }
27
28    pub fn style(mut self, style: impl Into<String>) -> Self {
29        self.style = Some(style.into());
30        self
31    }
32
33    pub fn image_data(mut self, id: impl Into<String>) -> Self {
34        self.image_data = Some(ImageData { id: id.into() });
35        self
36    }
37}
38
39// impl BuildXML for Shape {
40//     fn build(&self) -> Vec<u8> {
41//         let b = XMLBuilder::new();
42//         let mut b = b.open_pict();
43//         b = b.add_child(t),
44//         b.close().build()
45//     }
46// }