use core::fmt::Debug;
mod compare;
mod download_unzip_delete;
mod remote;
mod state;
use super::{FileSystem, RemoteZip};
use crate::{
model::{Config, Progress},
proto::sync::state::State,
};
#[derive(Debug)]
pub struct Statemachine<R: RemoteZip, F: FileSystem> {
internal: State<R, F>,
}
impl<R, F> Statemachine<R, F>
where
R: RemoteZip + Clone + Send + 'static,
F: FileSystem + Clone + Send + 'static,
{
pub fn new(remote: R, file_system: F, config: Config) -> Self {
Self {
internal: State::ToBeEvaluated(remote, file_system, config),
}
}
pub async fn progress(self) -> Option<(Progress<R::Error, F::Error>, Self)> {
self.internal
.progress()
.await
.map(|(progress, internal)| (progress, Self { internal }))
}
}