Skip to content

Commit

Permalink
Remove bounds from impl
Browse files Browse the repository at this point in the history
  • Loading branch information
opilar committed Apr 18, 2017
1 parent a46bd1b commit ea990e1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 56 deletions.
6 changes: 4 additions & 2 deletions src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ impl<R: Read> EncoderReader<R> {
inner: EncoderReaderBuf::new(BufReader::new(r), level),
}
}
}

impl<R> EncoderReader<R> {
/// Resets the state of this encoder entirely, swapping out the input
/// stream for another.
///
Expand Down Expand Up @@ -365,7 +367,7 @@ impl<R: AsyncWrite + BufRead> AsyncWrite for EncoderReaderBuf<R> {
}
}

impl<R: Read> DecoderReader<R> {
impl<R> DecoderReader<R> {
/// Creates a new decoder which will decompress data read from the given
/// stream.
pub fn new(r: R) -> DecoderReader<R> {
Expand Down Expand Up @@ -460,7 +462,7 @@ impl<R: AsyncWrite + AsyncRead> AsyncWrite for DecoderReader<R> {
}
}

impl<R: BufRead> DecoderReaderBuf<R> {
impl<R> DecoderReaderBuf<R> {
/// Creates a new decoder which will decompress data read from the given
/// stream.
pub fn new(r: R) -> DecoderReaderBuf<R> {
Expand Down
104 changes: 54 additions & 50 deletions src/gz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl<W: Write> Drop for EncoderWriter<W> {
}
}

impl<R: Read> EncoderReader<R> {
impl<R> EncoderReader<R> {
/// Creates a new encoder which will use the given compression level.
///
/// The encoder is not configured specially for the emitted header. For
Expand Down Expand Up @@ -435,7 +435,7 @@ impl<R: Read + Write> Write for EncoderReader<R> {
}
}

impl<R: BufRead> EncoderReaderBuf<R> {
impl<R> EncoderReaderBuf<R> {
/// Creates a new encoder which will use the given compression level.
///
/// The encoder is not configured specially for the emitted header. For
Expand Down Expand Up @@ -527,7 +527,9 @@ impl<R: Read> DecoderReader<R> {
DecoderReader { inner: r }
})
}
}

impl<R> DecoderReader<R> {
/// Returns the header associated with this stream.
pub fn header(&self) -> &Header {
self.inner.header()
Expand Down Expand Up @@ -638,30 +640,6 @@ impl<R: BufRead> DecoderReaderBuf<R> {
});
}


/// Returns the header associated with this stream.
pub fn header(&self) -> &Header {
&self.header
}

/// Acquires a reference to the underlying reader.
pub fn get_ref(&self) -> &R {
self.inner.get_ref().get_ref()
}

/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
/// this encoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}

/// Consumes this decoder, returning the underlying reader.
pub fn into_inner(self) -> R {
self.inner.into_inner().into_inner()
}

fn finish(&mut self) -> io::Result<()> {
if self.finished {
return Ok(());
Expand Down Expand Up @@ -695,6 +673,31 @@ impl<R: BufRead> DecoderReaderBuf<R> {
}
}

impl<R> DecoderReaderBuf<R> {
/// Returns the header associated with this stream.
pub fn header(&self) -> &Header {
&self.header
}

/// Acquires a reference to the underlying reader.
pub fn get_ref(&self) -> &R {
self.inner.get_ref().get_ref()
}

/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
/// this encoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}

/// Consumes this decoder, returning the underlying reader.
pub fn into_inner(self) -> R {
self.inner.into_inner().into_inner()
}
}

impl<R: BufRead> Read for DecoderReaderBuf<R> {
fn read(&mut self, into: &mut [u8]) -> io::Result<usize> {
match try!(self.inner.read(into)) {
Expand Down Expand Up @@ -735,30 +738,6 @@ impl<R: BufRead> MultiDecoderReaderBuf<R> {
});
}


/// Returns the current header associated with this stream.
pub fn header(&self) -> &Header {
&self.header
}

/// Acquires a reference to the underlying reader.
pub fn get_ref(&self) -> &R {
self.inner.get_ref().get_ref()
}

/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
/// this encoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}

/// Consumes this decoder, returning the underlying reader.
pub fn into_inner(self) -> R {
self.inner.into_inner().into_inner()
}

fn finish_member(&mut self) -> io::Result<usize> {
if self.finished {
return Ok(0);
Expand Down Expand Up @@ -808,6 +787,31 @@ impl<R: BufRead> MultiDecoderReaderBuf<R> {
}
}

impl<R> MultiDecoderReaderBuf<R> {
/// Returns the current header associated with this stream.
pub fn header(&self) -> &Header {
&self.header
}

/// Acquires a reference to the underlying reader.
pub fn get_ref(&self) -> &R {
self.inner.get_ref().get_ref()
}

/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
/// this encoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}

/// Consumes this decoder, returning the underlying reader.
pub fn into_inner(self) -> R {
self.inner.into_inner().into_inner()
}
}

impl<R: BufRead> Read for MultiDecoderReaderBuf<R> {
fn read(&mut self, into: &mut [u8]) -> io::Result<usize> {
match try!(self.inner.read(into)) {
Expand Down
8 changes: 4 additions & 4 deletions src/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<W: Read + Write> Read for EncoderWriter<W> {
impl<W: AsyncRead + AsyncWrite> AsyncRead for EncoderWriter<W> {
}

impl<R: Read> EncoderReader<R> {
impl<R> EncoderReader<R> {
/// Creates a new encoder which will read uncompressed data from the given
/// stream and emit the compressed stream.
pub fn new(r: R, level: ::Compression) -> EncoderReader<R> {
Expand Down Expand Up @@ -281,7 +281,7 @@ impl<R: AsyncRead + AsyncWrite> AsyncWrite for EncoderReader<R> {
}
}

impl<R: BufRead> EncoderReaderBuf<R> {
impl<R> EncoderReaderBuf<R> {
/// Creates a new encoder which will read uncompressed data from the given
/// stream and emit the compressed stream.
pub fn new(r: R, level: ::Compression) -> EncoderReaderBuf<R> {
Expand Down Expand Up @@ -365,7 +365,7 @@ impl<R: AsyncWrite + BufRead> AsyncWrite for EncoderReaderBuf<R> {
}
}

impl<R: Read> DecoderReader<R> {
impl<R> DecoderReader<R> {
/// Creates a new decoder which will decompress data read from the given
/// stream.
pub fn new(r: R) -> DecoderReader<R> {
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<R: AsyncWrite + AsyncRead> AsyncWrite for DecoderReader<R> {
}
}

impl<R: BufRead> DecoderReaderBuf<R> {
impl<R> DecoderReaderBuf<R> {
/// Creates a new decoder which will decompress data read from the given
/// stream.
pub fn new(r: R) -> DecoderReaderBuf<R> {
Expand Down

0 comments on commit ea990e1

Please sign in to comment.