docx_rs/documents/elements/
link.rs

1use serde::{Serialize, Serializer};
2
3use crate::documents::BuildXML;
4use crate::xml_builder::*;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct Link {
8    val: String,
9}
10
11impl Link {
12    pub fn new(val: impl Into<String>) -> Link {
13        Link { val: val.into() }
14    }
15}
16
17impl Serialize for Link {
18    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
19    where
20        S: Serializer,
21    {
22        serializer.serialize_str(&self.val)
23    }
24}
25
26impl BuildXML for Link {
27    fn build(&self) -> Vec<u8> {
28        let b = XMLBuilder::new();
29        b.link(&self.val).build()
30    }
31}