keepass/db/
meta.rs

1use chrono::NaiveDateTime;
2use uuid::Uuid;
3
4use crate::db::{Color, CustomData};
5
6/// Database metadata
7#[derive(Debug, Default, Eq, PartialEq, Clone)]
8#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
9pub struct Meta {
10    /// the program that generated the database file.
11    pub generator: Option<String>,
12
13    /// name of the database
14    pub database_name: Option<String>,
15
16    /// time the database name was last changed
17    pub database_name_changed: Option<NaiveDateTime>,
18
19    /// description of the database
20    pub database_description: Option<String>,
21
22    /// time the database description was last changed
23    pub database_description_changed: Option<NaiveDateTime>,
24
25    /// default username
26    pub default_username: Option<String>,
27
28    /// time the default username was last changed
29    pub default_username_changed: Option<NaiveDateTime>,
30
31    /// number of days of maintenance history to keep
32    pub maintenance_history_days: Option<usize>,
33
34    /// color code for the database
35    pub color: Option<Color>,
36
37    /// time the master key was last changed
38    pub master_key_changed: Option<NaiveDateTime>,
39
40    pub master_key_change_rec: Option<isize>,
41
42    pub master_key_change_force: Option<isize>,
43
44    /// memory protection settings
45    pub memory_protection: Option<MemoryProtection>,
46
47    /// custom icons
48    pub custom_icons: CustomIcons,
49
50    /// whether the recycle bin is enabled
51    pub recyclebin_enabled: Option<bool>,
52
53    /// A UUID for the recycle bin group
54    pub recyclebin_uuid: Option<Uuid>,
55
56    /// last time the recycle bin was changed
57    pub recyclebin_changed: Option<NaiveDateTime>,
58
59    /// UUID of the group containing entry templates
60    pub entry_templates_group: Option<Uuid>,
61
62    /// last time the group containing entry templates was changed
63    pub entry_templates_group_changed: Option<NaiveDateTime>,
64
65    /// UUID of the last selected group
66    pub last_selected_group: Option<Uuid>,
67
68    /// UUID of the last top-visible group
69    pub last_top_visible_group: Option<Uuid>,
70
71    /// Maximum number of items of history to keep
72    pub history_max_items: Option<usize>,
73
74    /// Maximum size of the history to keep
75    pub history_max_size: Option<usize>,
76
77    /// Last time the settings were changed
78    pub settings_changed: Option<NaiveDateTime>,
79
80    /// Binary attachments in the Metadata header
81    pub binaries: BinaryAttachments,
82
83    /// Additional custom data fields
84    pub custom_data: CustomData,
85}
86
87/// Database memory protection settings
88#[derive(Debug, PartialEq, Eq, Clone)]
89#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
90pub struct MemoryProtection {
91    /// Whether titles should be protected
92    pub protect_title: bool,
93
94    /// Whether user names should be protected
95    pub protect_username: bool,
96
97    /// Whether passwords should be protected
98    pub protect_password: bool,
99
100    /// Whether URLs should be protected
101    pub protect_url: bool,
102
103    /// Whether notes should be protected
104    pub protect_notes: bool,
105}
106
107impl Default for MemoryProtection {
108    fn default() -> Self {
109        Self {
110            protect_title: false,
111            protect_username: false,
112            protect_password: true,
113            protect_url: false,
114            protect_notes: false,
115        }
116    }
117}
118
119/// Collection of custom icons
120#[derive(Debug, Default, PartialEq, Eq, Clone)]
121#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
122pub struct CustomIcons {
123    pub icons: Vec<Icon>,
124}
125
126/// A custom icon
127#[derive(Debug, Default, PartialEq, Eq, Clone)]
128#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
129pub struct Icon {
130    /// UUID, to reference the icon
131    pub uuid: Uuid,
132
133    /// Image data
134    pub data: Vec<u8>,
135}
136
137/// Collection of binary attachments in the metadata of an XML database
138#[derive(Debug, Default, PartialEq, Eq, Clone)]
139#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
140pub struct BinaryAttachments {
141    pub binaries: Vec<BinaryAttachment>,
142}
143
144/// Binary attachment in the metadata of a XML database
145#[derive(Debug, Default, PartialEq, Eq, Clone)]
146#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
147pub struct BinaryAttachment {
148    pub identifier: Option<String>,
149    pub compressed: bool,
150    pub content: Vec<u8>,
151}