pub mod filesystem;
pub mod in_memory;
#[cfg(test)]
pub mod tests;
use super::util::close::Close;
use crate::error::IoPathResult;
use std::borrow::Cow;
use std::io::{Read, Write};
pub trait Storage {
type Reader: Read;
type Writer: Write + Close;
fn delete(&self, path: &str) -> IoPathResult<()>;
fn exists_file(&self, path: &str) -> IoPathResult<bool>;
fn get(&self, path: &str) -> IoPathResult<FileHandle<Self::Reader>>;
fn list(
&self,
path: &str,
) -> IoPathResult<impl Iterator<Item = IoPathResult<StorageEntry<'_>>>>;
fn put(&self, path: &str) -> IoPathResult<Self::Writer>;
}
pub struct FileHandle<Reader: Read> {
pub size_hint: u64,
pub reader: Reader,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EntryType {
File,
Directory,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StorageEntry<'a> {
pub entry_type: EntryType,
pub name: Cow<'a, String>,
pub size: u64,
}