docx_reader/types/
section_type.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use serde::{Deserialize, Serialize};
use std::fmt;
use std::str::FromStr;

use super::errors;

//
// Please see CT_SectType
//
// <xsd:enumeration value="nextPage"/>
// <xsd:enumeration value="nextColumn"/>
// <xsd:enumeration value="continuous"/>
// <xsd:enumeration value="evenPage"/>
// <xsd:enumeration value="oddPage"/>

#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum SectionType {
	NextPage,
	NextColumn,
	Continuous,
	EvenPage,
	OddPage,
}

impl fmt::Display for SectionType {
	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
		match *self {
			SectionType::NextPage => write!(f, "nextPage"),
			SectionType::NextColumn => write!(f, "nextColumn"),
			SectionType::Continuous => write!(f, "continuous"),
			SectionType::EvenPage => write!(f, "evenPage"),
			SectionType::OddPage => write!(f, "oddPage"),
		}
	}
}

impl FromStr for SectionType {
	type Err = errors::TypeError;
	fn from_str(s: &str) -> Result<Self, Self::Err> {
		match s {
			"nextPage" => Ok(SectionType::NextPage),
			"nextColumn" => Ok(SectionType::NextColumn),
			"continuous" => Ok(SectionType::Continuous),
			"evenPage" => Ok(SectionType::EvenPage),
			"oddPage" => Ok(SectionType::OddPage),
			_ => Ok(SectionType::Continuous),
		}
	}
}