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
use crate::types::errors;
use crate::TypeError;
use serde::*;
use std::str::FromStr;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum LineSpacingType {
    Auto,
    AtLeast,
    Exact,
}

impl FromStr for LineSpacingType {
    type Err = errors::TypeError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "auto" => Ok(LineSpacingType::Auto),
            "atLeast" => Ok(LineSpacingType::AtLeast),
            "exact" => Ok(LineSpacingType::Exact),
            _ => Err(TypeError::FromStrError),
        }
    }
}