Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Synchronous wrappers? idk
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Sep 12, 2021
1 parent f447ed7 commit 81476ff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/sync/mod.rs
Expand Up @@ -131,6 +131,23 @@ impl<'a, S: Destination<'a> + Send + 'a> Destination<'a> for Box<S> {
}
}

trait SynchronousSource {
type FilesIterator: Iterator<Item=(Vec<u8>, usize, HashDigest)>;
type FileBlocksIterator: Iterator<Item=(HashDigest, usize)>;

fn list_files(&self) -> Self::FilesIterator;
fn get_file_blocks(&self, name: &[u8]) -> Self::FileBlocksIterator;
fn get_block(&self, hash: &HashDigest) -> Vec<u8>;
}

trait SynchronousDestination {
type MissingBlocksIterator: Iterator<Item=HashDigest>;

fn add_file(&self, name: &[u8], size: usize, hash: &HashDigest);
fn set_file_blocks(&self, path: &[u8], hash: &HashDigest);
fn list_missing_blocks(&self) -> Self::MissingBlocksIterator;
}

pub async fn do_sync<'a, S: Source<'a> + 'a, R: Destination<'a> + 'a>(
mut source: S,
mut destination: R,
Expand Down

0 comments on commit 81476ff

Please sign in to comment.