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