use std::io::{Error, Read};
pub trait Vfs: Send + Sync + 'static {
type Reader: VfsReader;
fn open(&self, key: &str) -> Result<Self::Reader, Error>;
}
pub trait VfsReader: Read + Send + Sync + 'static {
fn get_size(&self) -> Result<u64, Error>;
}
pub trait Decoder {
type Output: Send + Sync;
type Error: std::error::Error;
fn decode<R: Read>(&self, reader: R) -> Result<Self::Output, Self::Error>;
fn estimate_cost(&self, item: &Self::Output) -> Result<u64, Self::Error>;
}
impl<T: Vfs> Vfs for std::sync::Arc<T> {
type Reader = T::Reader;
fn open(&self, key: &str) -> Result<Self::Reader, Error> {
(**self).open(key)
}
}