mod file;
mod mem;
use std::fmt::Debug;
use std::io::Result as IoResult;
use error::Result;
use base::crypto::{Crypto, Key};
use trans::{Eid, Txid};
pub use self::file::FileStorage;
pub use self::mem::MemStorage;
pub trait Storage: Debug {
fn exists(&self, location: &str) -> bool;
fn init(
&mut self,
volume_id: &Eid,
crypto: &Crypto,
skey: &Key,
) -> Result<()>;
fn get_super_blk(&self) -> Result<Vec<u8>>;
fn put_super_blk(&mut self, super_blk: &[u8]) -> Result<()>;
fn open(
&mut self,
volume_id: &Eid,
crypto: &Crypto,
skey: &Key,
) -> Result<Txid>;
fn read(
&mut self,
id: &Eid,
offset: u64,
buf: &mut [u8],
txid: Txid,
) -> IoResult<usize>;
fn write(
&mut self,
id: &Eid,
offset: u64,
buf: &[u8],
txid: Txid,
) -> IoResult<usize>;
fn del(&mut self, id: &Eid, txid: Txid) -> Result<Option<Eid>>;
fn begin_trans(&mut self, txid: Txid) -> Result<()>;
fn abort_trans(&mut self, txid: Txid) -> Result<()>;
fn commit_trans(&mut self, txid: Txid) -> Result<()>;
}