docx_reader/types/
section_type.rs1use serde::{Deserialize, Serialize};
2use std::fmt;
3use std::str::FromStr;
4
5use super::errors;
6
7#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
17#[serde(rename_all = "camelCase")]
18pub enum SectionType {
19 NextPage,
20 NextColumn,
21 Continuous,
22 EvenPage,
23 OddPage,
24}
25
26impl fmt::Display for SectionType {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match *self {
29 SectionType::NextPage => write!(f, "nextPage"),
30 SectionType::NextColumn => write!(f, "nextColumn"),
31 SectionType::Continuous => write!(f, "continuous"),
32 SectionType::EvenPage => write!(f, "evenPage"),
33 SectionType::OddPage => write!(f, "oddPage"),
34 }
35 }
36}
37
38impl FromStr for SectionType {
39 type Err = errors::TypeError;
40 fn from_str(s: &str) -> Result<Self, Self::Err> {
41 match s {
42 "nextPage" => Ok(SectionType::NextPage),
43 "nextColumn" => Ok(SectionType::NextColumn),
44 "continuous" => Ok(SectionType::Continuous),
45 "evenPage" => Ok(SectionType::EvenPage),
46 "oddPage" => Ok(SectionType::OddPage),
47 _ => Ok(SectionType::Continuous),
48 }
49 }
50}