keepass_ng/db/types/
icon.rs1use chrono::NaiveDateTime;
2use std::ops::{Deref, DerefMut};
3use uuid::Uuid;
4
5use crate::db::IconId;
6
7#[derive(Debug, Eq, PartialEq, Clone)]
9#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
10pub enum Icon {
11 BuiltIn(IconId),
13
14 Custom(Uuid),
16}
17
18#[derive(Debug, Clone, PartialEq, Eq)]
20#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
21pub struct CustomIcon {
22 pub(crate) id: Uuid,
23
24 pub name: Option<String>,
26
27 pub last_modification_time: Option<NaiveDateTime>,
29
30 pub data: Vec<u8>,
32}
33
34impl CustomIcon {
35 pub fn id(&self) -> Uuid {
37 self.id
38 }
39
40 pub fn name(&self) -> Option<&str> {
41 self.name.as_deref()
42 }
43
44 pub fn new(id: Uuid, name: Option<String>, last_modification_time: Option<NaiveDateTime>, data: Vec<u8>) -> Self {
45 Self {
46 id,
47 name,
48 last_modification_time,
49 data,
50 }
51 }
52}
53
54impl Deref for CustomIcon {
55 type Target = Vec<u8>;
56 fn deref(&self) -> &Self::Target {
57 &self.data
58 }
59}
60
61impl DerefMut for CustomIcon {
62 fn deref_mut(&mut self) -> &mut Self::Target {
63 &mut self.data
64 }
65}