From 37380c84b9a4ddb8dc59beab1f961a54eb31b643 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 2 Jul 2016 17:54:35 +0200 Subject: [PATCH] Add StoreId::unstorified() --- libimagstore/src/storeid.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { + self.strip_prefix(store.path()) + .map(PathBuf::from) + .map(StoreId::from) + .map_err_into(SEK::StoreIdHandlingError) + } + } impl Into for StoreId {