changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > demo / fig/src/lib.rs

changeset 11: d8f806f1d327
parent: 8f59e2f1b8c4
author: ellis <ellis@rwest.io>
date: Sun, 14 May 2023 21:27:04 -0400
permissions: -rw-r--r--
description: obj updates
1 //! fig/src/lib.rs --- Configuration types
2 use serde::{Serialize, Deserialize};
3 use obj::Objective;
4 use std::collections::HashMap as M;
5 use std::path::PathBuf;
6 use std::string::String as S;
7 use std::error::Error as E;
8 use std::boxed::Box as B;
9 type R<X> = std::result::Result<X,B<dyn E>>;
10 
11 /// common trait for all config modules. This trait provides functions
12 /// for de/serializing to/from RON, updating fields, and formatting.
13 pub trait Configure: Objective {
14  fn update(&self) -> R<()> {
15  Ok(())
16  }
17 }
18 
19 #[derive(Serialize, Deserialize, Debug, Default)]
20 pub struct ShellConfig {
21  pub env: M<S,S>,
22  pub cmds: M<S,S>,
23  pub shell: ShellType,
24 }
25 impl Objective for ShellConfig {}
26 
27 #[derive(Serialize, Deserialize, Debug, Hash, Default)]
28 pub enum ShellType {
29  #[default]
30  Bash,
31  Zsh,
32  Sh,
33 }
34 
35 #[derive(Serialize, Deserialize, Debug, Default)]
36 pub enum EditorType {
37  #[default]
38  Emacs,
39  Vi,
40  Nano,
41 }
42 
43 #[derive(Serialize, Deserialize, Debug, Default)]
44 pub struct EditorConfig {
45  pub editor: EditorType,
46  pub cmds: M<S,S>,
47  pub init_file: PathBuf,
48 }
49 
50 #[cfg(test)]
51 mod tests;