1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::{Attachment, DecryptionError, DecryptionKey, Id};
use url::Url;
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct Account {
pub id: Id,
pub name: String,
pub group: String,
pub url: Url,
pub note: String,
pub note_type: String,
pub favourite: bool,
pub username: String,
pub password: String,
pub password_protected: bool,
pub encrypted_attachment_key: String,
pub attachment_present: bool,
pub last_touch: String,
pub last_modified: String,
pub attachments: Vec<Attachment>,
}
impl Account {
pub fn attachment_key(
&self,
decryption_key: &DecryptionKey,
) -> Result<DecryptionKey, DecryptionError> {
let hex =
decryption_key.decrypt_base64(&self.encrypted_attachment_key)?;
let key = DecryptionKey::from_hex(&hex)?;
Ok(key)
}
}