2015-12-02 11:52:04 +00:00
|
|
|
use std::error::Error;
|
|
|
|
use std::fmt::{Debug, Display, Formatter};
|
|
|
|
use std::fmt;
|
|
|
|
use std::result::Result;
|
2015-11-23 17:42:55 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
|
|
|
pub type FileID = String;
|
|
|
|
|
2015-12-02 11:52:04 +00:00
|
|
|
pub struct FileIDError {
|
|
|
|
summary: String,
|
|
|
|
descrip: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FileIDError {
|
|
|
|
|
|
|
|
pub fn new(s: String, d: String) -> FileIDError {
|
|
|
|
FileIDError {
|
|
|
|
summary: s,
|
|
|
|
descrip: d,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Error for FileIDError {
|
|
|
|
|
|
|
|
fn description(&self) -> &str {
|
|
|
|
&self.summary[..]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn cause(&self) -> Option<&Error> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Debug for FileIDError {
|
|
|
|
|
|
|
|
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
|
|
|
|
write!(fmt, "FileIDError: '{}'\n{}", self.summary, self.descrip);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Display for FileIDError {
|
|
|
|
|
|
|
|
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
|
|
|
|
write!(fmt, "FileIDError: '{}'", self.summary);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type FileIDResult = Result<FileID, FileIDError>;
|
|
|
|
|
|
|
|
pub fn from_path_string(s: &String) -> FileIDResult {
|
2015-11-27 15:55:18 +00:00
|
|
|
unimplemented!()
|
2015-11-23 17:42:55 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 11:52:04 +00:00
|
|
|
pub fn from_path(p: &Path) -> FileIDResult {
|
2015-11-27 15:55:18 +00:00
|
|
|
unimplemented!()
|
2015-11-23 17:42:55 +00:00
|
|
|
}
|
|
|
|
|
2015-12-02 11:52:04 +00:00
|
|
|
pub fn from_pathbuf(p: &PathBuf) -> FileIDResult {
|
2015-11-23 17:42:55 +00:00
|
|
|
from_path(p.as_path())
|
|
|
|
}
|
|
|
|
|