docx_reader/types/
break_type.rs1use serde::{Deserialize, Serialize};
2
3use std::fmt;
8use std::str::FromStr;
9
10use super::errors;
11
12#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
13pub enum BreakType {
14 Page,
15 Column,
16 TextWrapping,
17 Unsupported,
18}
19
20impl fmt::Display for BreakType {
21 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
22 match *self {
23 BreakType::Page => write!(f, "page"),
24 BreakType::Column => write!(f, "column"),
25 BreakType::TextWrapping => write!(f, "textWrapping"),
26 BreakType::Unsupported => write!(f, "unsupported"),
27 }
28 }
29}
30
31impl FromStr for BreakType {
32 type Err = errors::TypeError;
33 fn from_str(s: &str) -> Result<Self, Self::Err> {
34 match s {
35 "page" => Ok(BreakType::Page),
36 "column" => Ok(BreakType::Column),
37 "textWrapping" => Ok(BreakType::TextWrapping),
38 _ => Ok(BreakType::Unsupported),
39 }
40 }
41}