[vault] Items: optional folder and attachments (SecretBytes), for KeePass groups and files
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! Typed items and their templates (docs/FORMAT.md, "Item types and their fields").
|
||||
|
||||
use crate::secret::SecretString;
|
||||
use crate::secret::{SecretBytes, SecretString};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
@@ -116,6 +116,19 @@ impl fmt::Debug for HistoryEntry {
|
||||
}
|
||||
}
|
||||
|
||||
/// A file kept with an item (imported from KeePass, docs/KDBX.md). The content counts as secret.
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Attachment {
|
||||
pub name: String,
|
||||
pub data: SecretBytes,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Attachment {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Attachment").field("name", &self.name).field("len", &self.data.len()).finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Item {
|
||||
pub id: String,
|
||||
@@ -132,6 +145,11 @@ pub struct Item {
|
||||
pub modified: i64,
|
||||
#[serde(default)]
|
||||
pub history: Vec<HistoryEntry>,
|
||||
/// Folder names, outermost first (a KeePass group path). Empty: no folder.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub folder: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub attachments: Vec<Attachment>,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
@@ -151,6 +169,8 @@ impl Item {
|
||||
created: now,
|
||||
modified: now,
|
||||
history: Vec::new(),
|
||||
folder: Vec::new(),
|
||||
attachments: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user