pub struct Database {
pub config: DatabaseConfig,
pub meta: Meta,
pub deleted_objects: HashMap<Uuid, Option<NaiveDateTime>>,
/* private fields */
}Expand description
A decrypted KeePass database
Fields§
§config: DatabaseConfigConfiguration settings of the database such as encryption and compression algorithms
meta: MetaMetadata of the KeePass database
deleted_objects: HashMap<Uuid, Option<NaiveDateTime>>References to previously-deleted objects and their deletion times.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(
source: &mut dyn Read,
key: DatabaseKey,
) -> Result<Database, DatabaseOpenError>
pub fn open( source: &mut dyn Read, key: DatabaseKey, ) -> Result<Database, DatabaseOpenError>
Parse a database from a std::io::Read
Sourcepub fn parse(
data: &[u8],
key: DatabaseKey,
) -> Result<Database, DatabaseOpenError>
pub fn parse( data: &[u8], key: DatabaseKey, ) -> Result<Database, DatabaseOpenError>
Parse a database from a byte slice
Sourcepub fn get_xml(
source: &mut dyn Read,
key: DatabaseKey,
) -> Result<Vec<u8>, DatabaseOpenError>
pub fn get_xml( source: &mut dyn Read, key: DatabaseKey, ) -> Result<Vec<u8>, DatabaseOpenError>
Helper function to load a database into its internal XML chunks
Sourcepub fn get_version(
source: &mut dyn Read,
) -> Result<DatabaseVersion, DatabaseOpenError>
pub fn get_version( source: &mut dyn Read, ) -> Result<DatabaseVersion, DatabaseOpenError>
Get the version of a database without decrypting it
Source§impl Database
impl Database
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new database with a single root group and no entries, groups, or attachments.
The root group will be assigned a new random UUID.
Sourcepub fn with_config(config: DatabaseConfig) -> Self
pub fn with_config(config: DatabaseConfig) -> Self
Create a new database with the given configuration and a single root group.
The root group will be assigned a new random UUID.
Sourcepub fn new_with_root_id(root_id: GroupId) -> Self
pub fn new_with_root_id(root_id: GroupId) -> Self
Create a new database with the given group UUID
Sourcepub fn root(&self) -> GroupRef<'_>
pub fn root(&self) -> GroupRef<'_>
Get an immutable reference to the root group of the database.
Sourcepub fn root_mut(&mut self) -> GroupMut<'_>
pub fn root_mut(&mut self) -> GroupMut<'_>
Get a mutable reference to the root group of the database.
Sourcepub fn recycle_bin(&self) -> Option<GroupRef<'_>>
pub fn recycle_bin(&self) -> Option<GroupRef<'_>>
Get an immutable reference to the recycle bin group, if it exists
Sourcepub fn recycle_bin_mut(&mut self) -> Option<GroupMut<'_>>
pub fn recycle_bin_mut(&mut self) -> Option<GroupMut<'_>>
Get a mutable reference to the recycle bin group, if it exists
Sourcepub fn num_attachments(&self) -> usize
pub fn num_attachments(&self) -> usize
Get the number of attachments in the database
Sourcepub fn num_custom_icons(&self) -> usize
pub fn num_custom_icons(&self) -> usize
Get the number of custom icons in the database
Sourcepub fn num_entries(&self) -> usize
pub fn num_entries(&self) -> usize
Get the number of entries in the database
Sourcepub fn num_groups(&self) -> usize
pub fn num_groups(&self) -> usize
Get the number of groups in the database, including the root group and the recycle bin (if it exists)
Sourcepub fn iter_all_attachments(
&self,
) -> impl Iterator<Item = AttachmentRef<'_>> + '_
pub fn iter_all_attachments( &self, ) -> impl Iterator<Item = AttachmentRef<'_>> + '_
Iterate over all attachments with immutable access.
Sourcepub fn foreach_attachment_mut<F>(&mut self, f: F)where
F: FnMut(AttachmentMut<'_>),
pub fn foreach_attachment_mut<F>(&mut self, f: F)where
F: FnMut(AttachmentMut<'_>),
Iterate over all attachments with mutable access. The provided closure is
called for each AttachmentMut and borrows are limited to the closure body.
Sourcepub fn iter_all_entries(&self) -> impl Iterator<Item = EntryRef<'_>> + '_
pub fn iter_all_entries(&self) -> impl Iterator<Item = EntryRef<'_>> + '_
Iterate over all entries with immutable access.
Sourcepub fn foreach_entry_mut<F>(&mut self, f: F)
pub fn foreach_entry_mut<F>(&mut self, f: F)
Iterate over all entries with mutable access. The provided closure is
called for each EntryMut and borrows are limited to the closure body.
Sourcepub fn iter_all_custom_icons(
&self,
) -> impl Iterator<Item = CustomIconRef<'_>> + '_
pub fn iter_all_custom_icons( &self, ) -> impl Iterator<Item = CustomIconRef<'_>> + '_
Iterate over all custom icons with immutable access.
Sourcepub fn foreach_custom_icon_mut<F>(&mut self, f: F)where
F: FnMut(CustomIconMut<'_>),
pub fn foreach_custom_icon_mut<F>(&mut self, f: F)where
F: FnMut(CustomIconMut<'_>),
Iterate over all custom icons with mutable access. The provided closure is
called for each CustomIconMut and borrows are limited to the closure body.
Sourcepub fn iter_all_groups(&self) -> impl Iterator<Item = GroupRef<'_>> + '_
pub fn iter_all_groups(&self) -> impl Iterator<Item = GroupRef<'_>> + '_
Iterate over all groups with immutable access. This includes the root group and the recycle bin (if it exists).
Sourcepub fn foreach_group_mut<F>(&mut self, f: F)
pub fn foreach_group_mut<F>(&mut self, f: F)
Iterate over all groups with mutable access. The provided closure is
called for each GroupMut and borrows are limited to the closure body.
Sourcepub fn attachment(&self, id: AttachmentId) -> Option<AttachmentRef<'_>>
pub fn attachment(&self, id: AttachmentId) -> Option<AttachmentRef<'_>>
Get an immutable reference to the attachment with the given ID, if it exists
Sourcepub fn attachment_mut(&mut self, id: AttachmentId) -> Option<AttachmentMut<'_>>
pub fn attachment_mut(&mut self, id: AttachmentId) -> Option<AttachmentMut<'_>>
Get a mutable reference to the attachment with the given ID, if it exists
Sourcepub fn custom_icon(&self, id: CustomIconId) -> Option<CustomIconRef<'_>>
pub fn custom_icon(&self, id: CustomIconId) -> Option<CustomIconRef<'_>>
Get an immutable reference to the custom icon with the given ID, if it exists
Sourcepub fn custom_icon_mut(&mut self, id: CustomIconId) -> Option<CustomIconMut<'_>>
pub fn custom_icon_mut(&mut self, id: CustomIconId) -> Option<CustomIconMut<'_>>
Get a mutable reference to the custom icon with the given ID, if it exists
Sourcepub fn entry(&self, id: EntryId) -> Option<EntryRef<'_>>
pub fn entry(&self, id: EntryId) -> Option<EntryRef<'_>>
Get an immutable reference to the entry with the given ID, if it exists
Sourcepub fn entry_mut(&mut self, id: EntryId) -> Option<EntryMut<'_>>
pub fn entry_mut(&mut self, id: EntryId) -> Option<EntryMut<'_>>
Get a mutable reference to the entry with the given ID, if it exists
Trait Implementations§
impl Eq for Database
impl StructuralPartialEq for Database
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
impl UnwindSafe for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.