PwFile

Struct PwFile 

Source
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: bool

Implementations§

Source§

impl PwFile

Source

pub fn iter(&self) -> Iter<'_, DbRecord>

Return iterator over all records

Source

pub fn groups(&self) -> HashSet<String>

Returns a list of all Groups in the database

Source

pub fn by_broup(&self, group: String) -> Vec<&DbRecord>

Returns all items in a group

Source

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}
Source

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§

Source§

impl Debug for PwFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V