docx_reader/documents/elements/
instr_text.rsuse serde::ser::{SerializeStruct, Serializer};
use serde::Serialize;
use crate::documents::*;
#[derive(Debug, Clone, PartialEq)]
pub enum InstrText {
TOC(InstrToC),
TC(InstrTC),
PAGEREF(InstrPAGEREF),
HYPERLINK(InstrHyperlink),
Unsupported(String),
}
impl Serialize for InstrText {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match *self {
InstrText::TOC(ref s) => {
let mut t = serializer.serialize_struct("TOC", 2)?;
t.serialize_field("type", "toc")?;
t.serialize_field("data", s)?;
t.end()
}
InstrText::TC(ref s) => {
let mut t = serializer.serialize_struct("TC", 2)?;
t.serialize_field("type", "tc")?;
t.serialize_field("data", s)?;
t.end()
}
InstrText::PAGEREF(ref s) => {
let mut t = serializer.serialize_struct("PAGEREF", 2)?;
t.serialize_field("type", "pageref")?;
t.serialize_field("data", s)?;
t.end()
}
InstrText::HYPERLINK(ref s) => {
let mut t = serializer.serialize_struct("HYPERLINK", 2)?;
t.serialize_field("type", "hyperlink")?;
t.serialize_field("data", s)?;
t.end()
}
InstrText::Unsupported(ref s) => {
let mut t = serializer.serialize_struct("Unsupported", 2)?;
t.serialize_field("type", "unsupported")?;
t.serialize_field("data", s)?;
t.end()
}
}
}
}