Add IsInDiary trait
This commit is contained in:
parent
f1be77081c
commit
2f3a52b2ab
1 changed files with 26 additions and 0 deletions
26
libimagdiary/src/is_in_diary.rs
Normal file
26
libimagdiary/src/is_in_diary.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use libimagstore::store::Entry;
|
||||
|
||||
pub trait IsInDiary {
|
||||
|
||||
fn is_in_diary(&self, name: &str) -> bool;
|
||||
|
||||
}
|
||||
|
||||
impl IsInDiary for Entry {
|
||||
|
||||
fn is_in_diary(&self, name: &str) -> bool {
|
||||
self.get_location().is_in_diary(name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl IsInDiary for PathBuf {
|
||||
|
||||
fn is_in_diary(&self, name: &str) -> bool {
|
||||
self.to_str().map(|s| s.contains(name)).unwrap_or(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue