blob: 8ae62b41a0e46d390b9378269451c68eb88c04ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
pub mod disk;
use super::Result;
use crate::server::blobref::BlobRef;
pub fn factory<'a, T: StorageBackend>(config: &T::Config) -> impl Fn(&'a str) -> T + '_ {
|bucket: &str| T::new(bucket, config)
}
pub trait StorageBackend: Iterator {
type Config;
fn new(bucket: &str, config: &Self::Config) -> Self;
fn put(&self, data: &[u8]) -> Result<BlobRef>;
fn get(&self, blobref: &BlobRef) -> Result<Option<Vec<u8>>>;
fn exists(&self, blobref: &BlobRef) -> bool {
if let Ok(Some(_)) = self.get(blobref) {
return true;
}
false
}
}
|