pub struct PwFile {
pub path: PathBuf,
pub db: PwDb,
pub is_open: bool,
pub is_valid: bool,
/* private fields */
}Expand description
High level abstraction of the PwSafe Database
§Example
use rs_pwsafe::PwFile;
let mut file = match PwFile::open("DevTest.psafe3") {
Ok(f) => f,
Err(e) => panic!("failed to open safe: {:?}", e)
};
match file.unlock("PswSafe123") {
Ok(_) => (),
Err(e) => panic!("failed to unlock db with {:?}", e)
}
for record in file.iter() {
println!("{:?}", record)
}Fields§
§path: PathBuf§db: PwDb§is_open: bool§is_valid: boolImplementations§
Source§impl PwFile
impl PwFile
Sourcepub fn unlock(&mut self, phrase: &str) -> Result<(), PwSafeError>
pub fn unlock(&mut self, phrase: &str) -> Result<(), PwSafeError>
Decrypt file data and load header and field
Examples found in repository?
examples/load_and_print.rs (line 7)
2fn main() {
3 let mut file = match PwFile::open("DevTest.psafe3") {
4 Ok(f) => f,
5 Err(e) => panic!("failed to open safe: {:?}", e)
6 };
7 match file.unlock("PswSafe123") {
8 Ok(_) => (),
9 Err(e) => panic!("failed to unlock db with {:?}", e)
10 }
11 println!("db-header: {:?}", file.db.header);
12 println!("db-record 1: {:?}", file.db.records.first().unwrap());
13}Sourcepub fn open(file_name: &str) -> Result<PwFile, PwSafeError>
pub fn open(file_name: &str) -> Result<PwFile, PwSafeError>
Read file and parse binary data in an acording struct
Examples found in repository?
examples/load_and_print.rs (line 3)
2fn main() {
3 let mut file = match PwFile::open("DevTest.psafe3") {
4 Ok(f) => f,
5 Err(e) => panic!("failed to open safe: {:?}", e)
6 };
7 match file.unlock("PswSafe123") {
8 Ok(_) => (),
9 Err(e) => panic!("failed to unlock db with {:?}", e)
10 }
11 println!("db-header: {:?}", file.db.header);
12 println!("db-record 1: {:?}", file.db.records.first().unwrap());
13}Trait Implementations§
Auto Trait Implementations§
impl Freeze for PwFile
impl RefUnwindSafe for PwFile
impl Send for PwFile
impl Sync for PwFile
impl Unpin for PwFile
impl UnwindSafe for PwFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more