use core::{fmt::Debug, future::Future};
use futures_lite::stream::Stream;
use std::ops::RangeInclusive;
use bytes::Bytes;
use crate::model::{FileInfo, RemoteFileInfo};
mod local_directory;
mod remote_file_info;
mod sync;
pub use local_directory::calculate_local_unix_path;
pub use remote_file_info::{RemoteFetchError, fetch_remote_file_info};
pub use sync::Statemachine;
pub trait FileSystem {
type Error: Debug + Send;
type StorePrepare: Send;
fn all_files(&mut self) -> impl Future<Output = Result<Vec<FileInfo>, Self::Error>> + Send;
fn prepare_store_file(
&self,
info: FileInfo,
) -> impl Future<Output = Result<Self::StorePrepare, Self::Error>> + Send;
fn store_file(
&self,
prepared: Self::StorePrepare,
data: Bytes,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn delete_file(&self, info: FileInfo) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
pub trait RemoteZip {
type Error: Debug + Send;
fn fetch_remote_file_info(&self) -> impl Future<Output = Result<Vec<RemoteFileInfo>, Self::Error>> + Send;
fn fetch_bytes_stream(
&self,
range: RangeInclusive<usize>,
) -> impl Future<Output = Result<impl Stream<Item = Result<Bytes, Self::Error>> + Send, Self::Error>> + Send;
}