Add StoreId::to_str() -> String

This commit is contained in:
Matthias Beyer 2016-08-24 15:55:26 +02:00
parent aa6f220659
commit 111cb4f29a
1 changed files with 15 additions and 0 deletions

View File

@ -5,6 +5,8 @@ use std::fmt::{Display, Debug, Formatter};
use std::fmt::Error as FmtError;
use std::result::Result as RResult;
use libimagerror::into::IntoError;
use error::StoreErrorKind as SEK;
use store::Result;
use store::Store;
@ -42,6 +44,19 @@ impl StoreId {
false
}
pub fn to_str(&self) -> Result<String> {
if self.base.is_some() {
let mut base = self.base.as_ref().cloned().unwrap();
base.push(self.id.clone());
base
} else {
self.id.clone()
}
.to_str()
.map(String::from)
.ok_or(SEK::StoreIdHandlingError.into_error())
}
}
impl Into<PathBuf> for StoreId {