use crate::misc::AccountError;
use async_trait::async_trait;
pub struct DirEntry {
pub path: String,
pub is_file: bool,
pub extension: Option<String>,
}
#[async_trait]
pub trait AsyncStreamWriter: Send + Sync {
async fn write_chunk(&mut self, data: &[u8]) -> Result<(), AccountError>;
async fn finish(self: Box<Self>) -> Result<(), AccountError>;
}
#[async_trait]
pub trait FileIO: Send + Sync + 'static {
async fn create_dir_all(&self, path: &str) -> Result<(), AccountError>;
async fn write_file(&self, path: &str, data: &[u8]) -> Result<(), AccountError>;
async fn read_file(&self, path: &str) -> Result<Vec<u8>, AccountError>;
async fn remove_file(&self, path: &str) -> Result<(), AccountError>;
async fn remove_dir_all(&self, path: &str) -> Result<(), AccountError>;
async fn read_dir(&self, path: &str) -> Result<Vec<DirEntry>, AccountError>;
async fn create_streaming_writer(
&self,
path: &str,
) -> Result<Box<dyn AsyncStreamWriter>, AccountError>;
}