pub struct Config {
pub mps_dir: PathBuf,
pub storage_dir: PathBuf,
pub log_file: PathBuf,
pub git_remote: String,
pub git_branch: String,
pub default_command: String,
pub aliases: HashMap<String, String>,
}Expand description
Mirrors ~/.mps_config.yaml written by the Ruby gem. Ruby uses symbol keys (:storage_dir) but the load() normaliser strips them.
Fields§
§mps_dir: PathBuf§storage_dir: PathBuf§log_file: PathBuf§git_remote: String§git_branch: String§default_command: StringWhich command mps (bare invocation) runs. Default: “open”. Ruby supports “list”.
aliases: HashMap<String, String>Short-hand type aliases: e.g. {“t”: “task”, “n”: “note”}
Implementations§
Source§impl Config
impl Config
Sourcepub fn default_config() -> Result<Self, MpsError>
pub fn default_config() -> Result<Self, MpsError>
Default config values using the user home directory.
Sourcepub fn load(path: &Path) -> Result<Self, MpsError>
pub fn load(path: &Path) -> Result<Self, MpsError>
Load config from a YAML file. Handles both string and symbol-prefixed keys (Ruby writes :storage_dir, Rust writes storage_dir).
Sourcepub fn init(path: &Path) -> Result<(), MpsError>
pub fn init(path: &Path) -> Result<(), MpsError>
Write default config to path. Does nothing if the file already exists.
Sourcepub fn ensure_dirs(&self) -> Result<(), MpsError>
pub fn ensure_dirs(&self) -> Result<(), MpsError>
Ensure mps_dir, storage_dir exist and log_file is present.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more