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