diff --git a/src/storage.rs b/src/storage.rs index 12d743ca..42f88ae4 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -1,69 +1,16 @@ pub use std::path::Path; pub use std::fs::File; +pub use std::error::Error; pub use runtime::Runtime; -pub use error::ImagError; -pub use error::ImagErrorBase; - -pub struct StorageError { - base : ImagErrorBase, - backendname : String, -} - -impl StorageError { - - pub fn new(backend : &T, short: String, long: String) -> StorageError { - StorageError { - base: ImagErrorBase { - shortdesc: short, - longdesc: long, - }, - backendname: backend.name() - } - } - -} - -impl<'a> ImagError<'a> for StorageError { - - fn print(&self, rt: &Runtime) { - if self.base.longdesc.is_empty() { - let s = format!("Backend {}: {}\n\n{}\n\n", - self.backendname, - self.base.shortdesc, - self.base.longdesc); - rt.print(&s) - } else { - let s = format!("Backend {}: {}\n", - self.backendname, - self.base.shortdesc); - rt.print(&s) - } - } - - fn print_short(&self, rt : &Runtime) { - let s = format!("Backend {}: {}\n", - self.backendname, - self.base.shortdesc); - rt.print(&s) - } - - fn print_long(&self, rt : &Runtime) { - let s = format!("Backend {}: {}\n\n{}\n\n", - self.backendname, - self.base.shortdesc, - self.base.longdesc); - rt.print(&s) - } -} pub trait StorageBackend { fn name(&self) -> String; - fn create(&self, file : File) -> Option; - fn read(&self, path: Path) -> Result; - fn update(&self, file : File) -> Option; - fn destroy(&self, path: Path) -> Option; + fn create(&self, file : File) -> Option; + fn read(&self, path: Path) -> Result; + fn update(&self, file : File) -> Option; + fn destroy(&self, path: Path) -> Option; }