feat: entry search

This commit is contained in:
electria 2026-08-26 12:35:59 -07:00
commit 7c86e3d496
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
2 changed files with 130 additions and 82 deletions

View file

@ -27,6 +27,17 @@ impl BasicField {
}
}
pub trait EntrySearchExt {
fn contains(&self, s: impl AsRef<str>) -> bool;
}
impl EntrySearchExt for keepass::db::EntryRef<'_> {
fn contains(&self, s: impl AsRef<str>) -> bool {
let str = s.as_ref();
self.get_title().is_some_and(|title| title.contains(str))
|| self.get_url().is_some_and(|url| url.contains(str))
}
}
pub fn get_last_opened() -> io::Result<String> {
Ok(fs::read_to_string(
dirs::data_dir()