-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
167 additions
and
110 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use rollsum; | ||
|
||
/// Abstraction over the specific chunking algorithms being used | ||
pub(crate) trait Chunking { | ||
fn find_chunk_edge(&mut self, &[u8]) -> Option<usize>; | ||
} | ||
|
||
pub(crate) struct Bup { | ||
engine: rollsum::Bup, | ||
} | ||
|
||
impl Bup { | ||
pub fn new(bits: u32) -> Self { | ||
Bup { | ||
engine: rollsum::Bup::new_with_chunk_bits(bits), | ||
} | ||
} | ||
} | ||
|
||
impl Chunking for Bup { | ||
fn find_chunk_edge(&mut self, data: &[u8]) -> Option<usize> { | ||
self.engine.find_chunk_edge(data) | ||
} | ||
} | ||
|
||
pub(crate) struct Gear { | ||
engine: rollsum::Gear, | ||
} | ||
|
||
|
||
impl Gear { | ||
pub fn new(bits: u32) -> Self { | ||
Gear { | ||
engine: rollsum::Gear::new_with_chunk_bits(bits), | ||
} | ||
} | ||
} | ||
|
||
|
||
impl Chunking for Gear { | ||
fn find_chunk_edge(&mut self, data: &[u8]) -> Option<usize> { | ||
self.engine.find_chunk_edge(data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters