Skip to main content

keepass/db/types/
meta.rs

1use std::collections::HashMap;
2
3use chrono::NaiveDateTime;
4use uuid::Uuid;
5
6use crate::db::{Color, CustomDataItem};
7
8/// Database metadata
9#[derive(Debug, Default, Eq, PartialEq, Clone)]
10#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
11pub struct Meta {
12    /// the program that generated the database file.
13    pub generator: Option<String>,
14
15    /// name of the database
16    pub database_name: Option<String>,
17
18    /// time the database name was last changed
19    pub database_name_changed: Option<NaiveDateTime>,
20
21    /// description of the database
22    pub database_description: Option<String>,
23
24    /// time the database description was last changed
25    pub database_description_changed: Option<NaiveDateTime>,
26
27    /// default username
28    pub default_username: Option<String>,
29
30    /// time the default username was last changed
31    pub default_username_changed: Option<NaiveDateTime>,
32
33    /// number of days of maintenance history to keep
34    pub maintenance_history_days: Option<usize>,
35
36    /// color code for the database
37    pub color: Option<Color>,
38
39    /// time the master key was last changed
40    pub master_key_changed: Option<NaiveDateTime>,
41
42    /// Number of days until a change of the master key is recommended. -1 means never.
43    pub master_key_change_rec: Option<isize>,
44
45    /// Number of days until a change of the master key is forced. -1 means never.
46    pub master_key_change_force: Option<isize>,
47
48    /// memory protection settings
49    pub memory_protection: Option<MemoryProtection>,
50
51    /// whether the recycle bin is enabled
52    pub recyclebin_enabled: Option<bool>,
53
54    /// A UUID for the recycle bin group
55    pub recyclebin_uuid: Option<Uuid>,
56
57    /// last time the recycle bin was changed
58    pub recyclebin_changed: Option<NaiveDateTime>,
59
60    /// UUID of the group containing entry templates
61    pub entry_templates_group: Option<Uuid>,
62
63    /// last time the group containing entry templates was changed
64    pub entry_templates_group_changed: Option<NaiveDateTime>,
65
66    /// UUID of the last selected group
67    pub last_selected_group: Option<Uuid>,
68
69    /// UUID of the last top-visible group
70    pub last_top_visible_group: Option<Uuid>,
71
72    /// Maximum number of items of history to keep
73    pub history_max_items: Option<isize>,
74
75    /// Maximum size of the history to keep
76    pub history_max_size: Option<isize>,
77
78    /// Last time the settings were changed
79    pub settings_changed: Option<NaiveDateTime>,
80
81    /// Additional custom data fields
82    pub custom_data: HashMap<String, CustomDataItem>,
83}
84
85/// Database memory protection settings
86#[derive(Debug, PartialEq, Eq, Clone)]
87#[cfg_attr(feature = "serialization", derive(serde::Serialize))]
88pub struct MemoryProtection {
89    /// Whether titles should be protected
90    pub protect_title: bool,
91
92    /// Whether user names should be protected
93    pub protect_username: bool,
94
95    /// Whether passwords should be protected
96    pub protect_password: bool,
97
98    /// Whether URLs should be protected
99    pub protect_url: bool,
100
101    /// Whether notes should be protected
102    pub protect_notes: bool,
103}
104
105impl Default for MemoryProtection {
106    fn default() -> Self {
107        Self {
108            protect_title: false,
109            protect_username: false,
110            protect_password: true,
111            protect_url: false,
112            protect_notes: false,
113        }
114    }
115}