imag/libimagdiary/src/is_in_diary.rs
Matthias Beyer ccffeb91a2 Remove StoreId::is_in_collection(), add StoreId::local()
Having a ::is_in_collection() is a nice thing, though it is _way_ better
if we just give the user of the `StoreId` object access to the local
part of the ID.

Using this new function, one can do all the actions one might need on
the Path for the actual entry without nasty copying or such.

`StoreId::is_in_collection()` can be replaced by
`StoreId::local().starts_with()` and everything is fine, as we do not
have to move a `PathBuf` object into the function anymore.
2016-09-04 10:40:38 +02:00

25 lines
431 B
Rust

use libimagstore::store::Entry;
use libimagstore::storeid::StoreId;
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().clone().is_in_diary(name)
}
}
impl IsInDiary for StoreId {
fn is_in_diary(&self, name: &str) -> bool {
self.local().starts_with(format!("diary/{}", name))
}
}