Add StoreId::to_str() -> String
This commit is contained in:
parent
aa6f220659
commit
111cb4f29a
1 changed files with 15 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue