file_chunker: use Read trait

This commit is contained in:
Dietmar Maurer 2018-12-15 11:08:49 +01:00
parent fc8b19368a
commit 48e8689505
1 changed files with 4 additions and 3 deletions

View File

@ -25,12 +25,13 @@ fn required_string_param<'a>(param: &'a Value, name: &str) -> &'a str {
// Note: We cannot implement an Iterator, because Iterators cannot // Note: We cannot implement an Iterator, because Iterators cannot
// return a borrowed buffer ref (we want zero-copy) // return a borrowed buffer ref (we want zero-copy)
fn file_chunker<C>( fn file_chunker<C, R>(
mut file: File, mut file: R,
chunk_size: usize, chunk_size: usize,
chunk_cb: C chunk_cb: C
) -> Result<(), Error> ) -> Result<(), Error>
where C: Fn(usize, &[u8]) -> Result<bool, Error> where C: Fn(usize, &[u8]) -> Result<bool, Error>,
R: Read,
{ {
const read_buffer_size: usize = 4*1024*1024; // 4M const read_buffer_size: usize = 4*1024*1024; // 4M