1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-02 01:05:08 +02:00

rename flate2-c feature to flate2-zlib

This commit is contained in:
Nikolay Kim
2019-03-26 18:46:06 -07:00
parent 1904b01fc0
commit 2629699b62
7 changed files with 48 additions and 32 deletions

View File

@ -5,7 +5,7 @@ use futures::{Async, Poll, Stream};
#[cfg(feature = "brotli")]
use brotli2::write::BrotliDecoder;
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
use flate2::write::{GzDecoder, ZlibDecoder};
use super::Writer;
@ -27,11 +27,11 @@ where
ContentEncoding::Br => Some(ContentDecoder::Br(Box::new(
BrotliDecoder::new(Writer::new()),
))),
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentEncoding::Deflate => Some(ContentDecoder::Deflate(Box::new(
ZlibDecoder::new(Writer::new()),
))),
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentEncoding::Gzip => Some(ContentDecoder::Gzip(Box::new(
GzDecoder::new(Writer::new()),
))),
@ -95,15 +95,16 @@ where
}
enum ContentDecoder {
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
Deflate(Box<ZlibDecoder<Writer>>),
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
Gzip(Box<GzDecoder<Writer>>),
#[cfg(feature = "brotli")]
Br(Box<BrotliDecoder<Writer>>),
}
impl ContentDecoder {
#[allow(unreachable_patterns)]
fn feed_eof(&mut self) -> io::Result<Option<Bytes>> {
match self {
#[cfg(feature = "brotli")]
@ -118,7 +119,7 @@ impl ContentDecoder {
}
Err(e) => Err(e),
},
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentDecoder::Gzip(ref mut decoder) => match decoder.try_finish() {
Ok(_) => {
let b = decoder.get_mut().take();
@ -130,7 +131,7 @@ impl ContentDecoder {
}
Err(e) => Err(e),
},
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentDecoder::Deflate(ref mut decoder) => match decoder.try_finish() {
Ok(_) => {
let b = decoder.get_mut().take();
@ -142,12 +143,14 @@ impl ContentDecoder {
}
Err(e) => Err(e),
},
_ => Ok(None),
}
}
#[allow(unreachable_patterns)]
fn feed_data(&mut self, data: Bytes) -> io::Result<Option<Bytes>> {
match self {
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentDecoder::Br(ref mut decoder) => match decoder.write_all(&data) {
Ok(_) => {
decoder.flush()?;
@ -160,7 +163,7 @@ impl ContentDecoder {
}
Err(e) => Err(e),
},
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentDecoder::Gzip(ref mut decoder) => match decoder.write_all(&data) {
Ok(_) => {
decoder.flush()?;
@ -173,7 +176,7 @@ impl ContentDecoder {
}
Err(e) => Err(e),
},
#[cfg(any(feature = "flate2-c", feature = "flate2-rust"))]
#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
ContentDecoder::Deflate(ref mut decoder) => match decoder.write_all(&data) {
Ok(_) => {
decoder.flush()?;
@ -186,6 +189,7 @@ impl ContentDecoder {
}
Err(e) => Err(e),
},
_ => Ok(Some(data)),
}
}
}