pub fn load_meta_data_from_file(path: String) -> Result<String, String> {
    // Assemble file path
    let file_path: String = format!("{}/kvsd-meta-data.json", path);
    // check whether file exists
    if !Path::new(&file_path).exists() {
        return Ok("No meta-data file available.".to_string());
    }
    // load encrypted string
    let encrypted_string = match read_file_to_string(file_path) {
        Ok(json) => json,
        Err(e) => return Err(format!("Could not read stored meta-data file: {}", e)),
    };
    // Decrypt content
    let json_string = json_decrypt(encrypted_string);
    // parse decrypted string
    let v: HashMap<String, ValueMetaData> = match serde_json::from_str(json_string.as_str()) {
        Ok(val) => val,
        Err(e) => return Err(format!("Could not parse json: {}", e)),
    };
    // for each element in array
    STORE.write().unwrap().elements = v;
    // insert element in store
    Ok("Loaded stored meta-data from file.".to_string())
}
// Initializes the store from the local json file on start-up.
Initializes the store from the local json file on start-up.
Initializes the store from the local json file on start - up .
pub fn load_meta_data_from_file(path: String) -> Result<String, String> {
    // Assemble file path
    let file_path: String = format!("{}/kvsd-meta-data.json", path);
    // check whether file exists
    if !Path::new(&file_path).exists() {
        return Ok("No meta-data file available.".to_string());
    }
    // load encrypted string
    let encrypted_string = match read_file_to_string(file_path) {
        Ok(json) => json,
        Err(e) => return Err(format!("Could not read stored meta-data file: {}", e)),
    };
    // Decrypt content
    let json_string = json_decrypt(encrypted_string);
    // parse decrypted string
    let v: HashMap<String, ValueMetaData> = match serde_json::from_str(json_string.as_str()) {
        Ok(val) => val,
        Err(e) => return Err(format!("Could not parse json: {}", e)),
    };
    // for each element in array
    STORE.write().unwrap().elements = v;
    // insert element in store
    Ok("Loaded stored meta-data from file.".to_string())
}
pub fn load_meta_data_from_file ( path : String ) -> Result < String , String > { // Assemble file path let file_path : String = format ! ( " " path ) ; // check whether file exists if ! Path :: new ( & file_path ) . exists ( ) { return Ok ( " " . to_string ( ) ) ; } // load encrypted string let encrypted_string = match read_file_to_string ( file_path ) { Ok ( json ) => json , Err ( e ) => return Err ( format ! ( " " e ) ) , } ; // Decrypt content let json_string = json_decrypt ( encrypted_string ) ; // parse decrypted string let v : HashMap < String , ValueMetaData > = match serde_json :: from_str ( json_string . as_str ( ) ) { Ok ( val ) => val , Err ( e ) => return Err ( format ! ( " " e ) ) , } ; // for each element in array STORE . write ( ) . unwrap ( ) . elements = v ; // insert element in store Ok ( " " . to_string ( ) ) }
Initializes the store from the local json file on start-up.
Initializes the store from the local json file on start - up .
path
String
path
String