nu_data/config/
conf.rs

1use nu_errors::ShellError;
2use nu_protocol::Value;
3use std::{fmt::Debug, path::PathBuf};
4
5pub trait Conf: Debug + Send {
6    fn is_modified(&self) -> Result<bool, Box<dyn std::error::Error>>;
7    fn var(&self, key: &str) -> Option<Value>;
8    fn env(&self) -> Option<Value>;
9    fn path(&self) -> Result<Option<Vec<PathBuf>>, ShellError>;
10    fn clone_box(&self) -> Box<dyn Conf>;
11    fn reload(&mut self);
12}
13
14impl Conf for Box<dyn Conf> {
15    fn is_modified(&self) -> Result<bool, Box<dyn std::error::Error>> {
16        (**self).is_modified()
17    }
18
19    fn var(&self, key: &str) -> Option<Value> {
20        (**self).var(key)
21    }
22
23    fn env(&self) -> Option<Value> {
24        (**self).env()
25    }
26
27    fn reload(&mut self) {
28        (**self).reload();
29    }
30
31    fn clone_box(&self) -> Box<dyn Conf> {
32        (**self).clone_box()
33    }
34
35    fn path(&self) -> Result<Option<Vec<PathBuf>>, ShellError> {
36        (**self).path()
37    }
38}