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
use serde::{Deserialize, Serialize};
use std::fmt;
use std::str::FromStr;
use wasm_bindgen::prelude::*;
use super::errors;
#[wasm_bindgen]
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq)]
pub enum BreakType {
Page,
Column,
TextWrapping,
Unsupported,
}
impl fmt::Display for BreakType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BreakType::Page => write!(f, "page"),
BreakType::Column => write!(f, "column"),
BreakType::TextWrapping => write!(f, "textWrapping"),
BreakType::Unsupported => write!(f, "unsupported"),
}
}
}
impl FromStr for BreakType {
type Err = errors::TypeError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"page" => Ok(BreakType::Page),
"column" => Ok(BreakType::Column),
"textWrapping" => Ok(BreakType::TextWrapping),
_ => Ok(BreakType::Unsupported),
}
}
}