pub fn load(path: &PathBuf) -> Result<Store,UnusableStore> {
        if path.exists() {
            info!("Reading config file {}", path.to_string_lossy());
            // First read the file
            let mut file = File::open(path)?;
            let mut contents = String::new();
            file.read_to_string(&mut contents)?;
            // Then deserialize its content
            let mut store: Store =
                serde_json::from_str(&contents)?;
            store.path = path.to_owned();
            // And return it
            Ok(store)
        } else {
            info!("Using fresh config file {}", path.to_string_lossy());
            Ok(Store {
                settings: Settings::default(),
                feeds: vec![],
                dirty: false,
                path: path.to_owned()
            })
        }
    }
/// Initialize a Store object from a config file at the given path. If the
/// config file does not exist, return a Store object with default values.

Initialize a Store object from a config file at the given path. If the
config file does not exist, return a Store object with default values.
Initialize a Store object from a config file at the given path . If the config file does not exist return a Store object with default values .
pub fn load(path: &PathBuf) -> Result<Store,UnusableStore> {
        if path.exists() {
            info!("Reading config file {}", path.to_string_lossy());
            // First read the file
            let mut file = File::open(path)?;
            let mut contents = String::new();
            file.read_to_string(&mut contents)?;
            // Then deserialize its content
            let mut store: Store =
                serde_json::from_str(&contents)?;
            store.path = path.to_owned();
            // And return it
            Ok(store)
        } else {
            info!("Using fresh config file {}", path.to_string_lossy());
            Ok(Store {
                settings: Settings::default(),
                feeds: vec![],
                dirty: false,
                path: path.to_owned()
            })
        }
    }
pub fn load ( path : & PathBuf ) -> Result < Store , UnusableStore > { if path . exists ( ) { info ! ( " " path to_string_lossy ( ) ) ; // First read the file
 let mut file = File :: open ( path ) ? ; let mut contents = String :: new ( ) ; file . read_to_string ( & mut contents ) ? ; // Then deserialize its content
 let mut store : Store = serde_json :: from_str ( & contents ) ? ; store . path = path . to_owned ( ) ; // And return it
 Ok ( store ) } else { info ! ( " " path to_string_lossy ( ) ) ; Ok ( Store { settings : Settings :: default ( ) , feeds : vec ! [ ] , dirty : false , path : path . to_owned ( ) } ) } }
Initialize a Store object from a config file at the given path.
Initialize a Store object from a config file at the given path .
path
&PathBuf
path
&PathBuf