src/config/serde.rs
30 lines · 788 bytes
1//! Structs that impl `Into<T>` because `T` does not impl Serde but is used in config files
2
3use serde::{Deserialize, Serialize};
4use tui::widgets::BorderType;
5
6/// `BorderType` but impl `serde`
7#[derive(Serialize, Deserialize, Clone, Copy)]
8pub enum BorderTypeSerde {
9 Plain,
10 Rounded,
11 Double,
12 Thick,
13}
14
15impl Default for BorderTypeSerde {
16 fn default() -> Self {
17 Self::Rounded
18 }
19}
20
21impl From<BorderTypeSerde> for BorderType {
22 fn from(origianl: BorderTypeSerde) -> BorderType {
23 match origianl {
24 BorderTypeSerde::Plain => BorderType::Plain,
25 BorderTypeSerde::Rounded => BorderType::Rounded,
26 BorderTypeSerde::Thick => BorderType::Thick,
27 BorderTypeSerde::Double => BorderType::Double,
28 }
29 }
30}