From c052be5c86daac745e0deabfd4b31eeb32643d7a Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 22 May 2019 09:18:05 +0200 Subject: [PATCH] src/backup/chunk_stream.rs: use more generics --- src/backup/chunk_stream.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/backup/chunk_stream.rs b/src/backup/chunk_stream.rs index a3272408..040c7c77 100644 --- a/src/backup/chunk_stream.rs +++ b/src/backup/chunk_stream.rs @@ -5,21 +5,24 @@ use futures::{Async, Poll}; use futures::stream::Stream; /// Split input stream into dynamic sized chunks -pub struct ChunkStream, Error=Error>> { +pub struct ChunkStream { input: S, chunker: Chunker, buffer: Option>, scan: Option>, } -impl , Error=Error>> ChunkStream { - +impl ChunkStream { pub fn new(input: S) -> Self { Self { input, chunker: Chunker::new(4 * 1024 * 1024), buffer: None, scan: None} } } -impl , Error=Error>> Stream for ChunkStream { +impl Stream for ChunkStream + where S: Stream, + S::Item: AsRef<[u8]>, + S::Error: Into, +{ type Item = Vec; type Error = Error; @@ -49,7 +52,7 @@ impl , Error=Error>> Stream for ChunkStream { match self.input.poll() { Err(err) => { - return Err(err); + return Err(err.into()); } Ok(Async::NotReady) => { return Ok(Async::NotReady); @@ -66,7 +69,7 @@ impl , Error=Error>> Stream for ChunkStream { } Ok(Async::Ready(Some(data))) => { let scan = self.scan.get_or_insert_with(|| Vec::with_capacity(1024*1024)); - scan.extend(data); + scan.extend(data.as_ref()); } } }