docx_rs/types/
section_type.rs

1use serde::{Deserialize, Serialize};
2
3//
4// Please see CT_SectType
5//
6// <xsd:enumeration value="nextPage"/>
7// <xsd:enumeration value="nextColumn"/>
8// <xsd:enumeration value="continuous"/>
9// <xsd:enumeration value="evenPage"/>
10// <xsd:enumeration value="oddPage"/>
11
12use std::fmt;
13use std::str::FromStr;
14#[cfg(feature = "wasm")]
15use wasm_bindgen::prelude::*;
16
17use super::errors;
18
19#[cfg_attr(feature = "wasm", wasm_bindgen)]
20#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
21#[serde(rename_all = "camelCase")]
22pub enum SectionType {
23    NextPage,
24    NextColumn,
25    Continuous,
26    EvenPage,
27    OddPage,
28}
29
30impl fmt::Display for SectionType {
31    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32        match *self {
33            SectionType::NextPage => write!(f, "nextPage"),
34            SectionType::NextColumn => write!(f, "nextColumn"),
35            SectionType::Continuous => write!(f, "continuous"),
36            SectionType::EvenPage => write!(f, "evenPage"),
37            SectionType::OddPage => write!(f, "oddPage"),
38        }
39    }
40}
41
42impl FromStr for SectionType {
43    type Err = errors::TypeError;
44    fn from_str(s: &str) -> Result<Self, Self::Err> {
45        match s {
46            "nextPage" => Ok(SectionType::NextPage),
47            "nextColumn" => Ok(SectionType::NextColumn),
48            "continuous" => Ok(SectionType::Continuous),
49            "evenPage" => Ok(SectionType::EvenPage),
50            "oddPage" => Ok(SectionType::OddPage),
51            _ => Ok(SectionType::Continuous),
52        }
53    }
54}