diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-07-02 17:54:35 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-07-04 12:44:58 +0200 |
commit | 37380c84b9a4ddb8dc59beab1f961a54eb31b643 (patch) | |
tree | 09a2bb5b95bff6280cc6d58e2da3c4cabe069edc /libimagstore | |
parent | 12b8f8f33105ca340700fd63ff004a3773b0fb47 (diff) |
Add StoreId::unstorified()
Diffstat (limited to 'libimagstore')
-rw-r--r-- | libimagstore/src/storeid.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index 48f8b834..93c19dd7 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -9,6 +9,7 @@ use std::fmt::Error as FmtError; use std::result::Result as RResult; use error::StoreErrorKind as SEK; +use error::MapErrInto; use store::Result; use store::Store; @@ -26,6 +27,13 @@ impl StoreId { StoreId::from(new_id) } + pub fn unstorified(self, store: &Store) -> Result<StoreId> { + self.strip_prefix(store.path()) + .map(PathBuf::from) + .map(StoreId::from) + .map_err_into(SEK::StoreIdHandlingError) + } + } impl Into<PathBuf> for StoreId { |