/// Attemps to read the configuration file from disk. If it succeeds, it
/// returns the read configuration. Otherwise, it returns the default
/// configuration.
Attemps to read the configuration file from disk. If it succeeds, it
returns the read configuration. Otherwise, it returns the default
configuration.
Attemps to read the configuration file from disk . If it succeeds it returns the read configuration . Otherwise it returns the default configuration .
pub fn read<T: AsRef<Path>, U: AsRef<Path>>(config_dir: T, config_path: U) -> Self {
        let config_dir = config_dir.as_ref();
        // Creates the configuration folder if it doesn't exist.
        if !config_dir.exists() {
            println!("Could not find the configuration directory, creating it!");
            if let Err(err) = fs::create_dir_all(&config_dir) {
                eprintln!("Could not create the configuration directory: {}", err);
                return Default::default();
            }
        }
        let config_path = config_path.as_ref();
        // We read from the configuration file and return its contents.
        if config_path.exists() {
            Self::from_path(config_path).unwrap_or_default()
        }
        // Creates the configuration file if it doesn't exist.
        else {
            println!("Could not find the configuration file, creating it!");
            let config = Self::default();
            config.save(config_path);
            config
        }
    }
pub fn read < T : AsRef < Path > , U : AsRef < Path > > ( config_dir : T , config_path : U ) -> Self { let config_dir = config_dir . as_ref ( ) ; // Creates the configuration folder if it doesn't exist. if ! config_dir . exists ( ) { println ! ( " " ) ; if let Err ( err ) = fs :: create_dir_all ( & config_dir ) { eprintln ! ( " " err ) ; return Default :: default ( ) ; } } let config_path = config_path . as_ref ( ) ; // We read from the configuration file and return its contents. if config_path . exists ( ) { Self :: from_path ( config_path ) . unwrap_or_default ( ) } // Creates the configuration file if it doesn't exist. else { println ! ( " " ) ; let config = Self :: default ( ) ; config . save ( config_path ) ; config } }
Attemps to read the configuration file from disk.
Attemps to read the configuration file from disk .
config_dir
T
config_path
U