docx_reader/types/
height_rule.rs1use serde::Serialize;
2use std::fmt;
3use std::str::FromStr;
4
5use super::errors;
6
7#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub enum HeightRule {
10 Auto,
11 AtLeast,
12 Exact,
13}
14
15impl Default for HeightRule {
16 fn default() -> Self {
17 Self::AtLeast
18 }
19}
20
21impl fmt::Display for HeightRule {
22 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23 match *self {
24 HeightRule::Auto => write!(f, "auto"),
25 HeightRule::AtLeast => write!(f, "atLeast"),
26 HeightRule::Exact => write!(f, "exact"),
27 }
28 }
29}
30
31impl FromStr for HeightRule {
32 type Err = errors::TypeError;
33 fn from_str(s: &str) -> Result<Self, Self::Err> {
34 match s {
35 "auto" => Ok(HeightRule::Auto),
36 "atLeast" => Ok(HeightRule::AtLeast),
37 "exact" => Ok(HeightRule::Exact),
38 _ => Ok(HeightRule::AtLeast),
39 }
40 }
41}