/// Write an account to a json file
Write an account to a json file
Write an account to a json file
pub fn write_account(file_path: &str, account: &Account) -> Result<(), String>{
    // Try to encode the Account into json
    let s = match json::encode(account) {
        Ok(e_val) => e_val,
        Err(r) => return Err(String::from("Failed to encode Account: ")
                             + r.to_string().as_ref()),
    };
    // Try to write the json to the file
    match write_file(&file_path, &s) {
        Ok(_) => return Ok(()),
        Err(r) => return Err(r)
    };
}
pub fn write_account ( file_path : & str , account : & Account ) -> Result < ( ) , String > { // Try to encode the Account into json let s = match json :: encode ( account ) { Ok ( e_val ) => e_val , Err ( r ) => return Err ( String :: from ( " " ) + r . to_string ( ) . as_ref ( ) ) , } ; // Try to write the json to the file match write_file ( & file_path , & s ) { Ok ( _ ) => return Ok ( ( ) ) , Err ( r ) => return Err ( r ) } ; }
Write an account to a json file
Write an account to a json file
file_path
&str
account
&Account