cotp 0.1.3

Trustworthy command line authenticator app compatible with backups from andOTP, Aegis and so on..
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::database_loader::OTPElement;
use std::fs::read_to_string;

//no need to declare andOTP json struct cause it's the same as OTP element

pub fn import(filepath: &str) -> Result<Vec<OTPElement>,String>{
    let file_to_import_contents = read_to_string(filepath).unwrap();
    let result: Result<Vec<OTPElement>,serde_json::Error> = serde_json::from_str(&file_to_import_contents);
    match result {
        Ok(element) => return Ok(element),
        Err(e) => return Err(String::from(format!("Failed to serialize file: {}",e)))
    }
}