Skip to main content

keepass_ng/db/types/
attachment.rs

1use std::ops::{Deref, DerefMut};
2
3use crate::db::Value;
4
5/// Attachment for an entry.
6///
7/// Both header attachments (KDBX4-style) and XML attachments (KDBX3-style) will be converted to
8/// this format when parsing.
9#[derive(Debug, Default, PartialEq, Eq, Clone)]
10#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
11pub struct Attachment {
12    /// The binary data of the attachment.
13    pub data: Value<Vec<u8>>,
14}
15
16impl Deref for Attachment {
17    type Target = Value<Vec<u8>>;
18
19    fn deref(&self) -> &Self::Target {
20        &self.data
21    }
22}
23
24impl DerefMut for Attachment {
25    fn deref_mut(&mut self) -> &mut Self::Target {
26        &mut self.data
27    }
28}