Skip to content

Commit

Permalink
fix compilation errors when only a subset of compression features is …
Browse files Browse the repository at this point in the history
…enabled
  • Loading branch information
valkum committed Oct 8, 2024
1 parent ce852a4 commit d2035be
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions mendes/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,23 @@ impl http_body::Body for Body {
#[cfg(feature = "hyper")]
(false, InnerBody::Hyper(inner)) => inner.size_hint(),
(false, InnerBody::Lazy { .. } | InnerBody::Streaming(_)) => SizeHint::default(),
#[cfg(any(feature = "brotli", feature = "gzip", feature = "zlib"))]
(false, InnerBody::Brotli(_) | InnerBody::Zlib(_) | InnerBody::Gzip(_)) => {
// The duplication here is pretty ugly, but I couldn't come up with anything better.
#[cfg(feature = "brotli")]
(false, InnerBody::Brotli(_)) => {
let mut hint = SizeHint::default();
hint.set_lower(1);
hint.set_upper(self.full_size + 256);
hint

Check warning on line 199 in mendes/src/body.rs

View check run for this annotation

Codecov / codecov/patch

mendes/src/body.rs#L196-L199

Added lines #L196 - L199 were not covered by tests
}
#[cfg(feature = "gzip")]
(false, InnerBody::Gzip(_)) => {
let mut hint = SizeHint::default();
hint.set_lower(1);
hint.set_upper(self.full_size + 256);
hint

Check warning on line 206 in mendes/src/body.rs

View check run for this annotation

Codecov / codecov/patch

mendes/src/body.rs#L203-L206

Added lines #L203 - L206 were not covered by tests
}
#[cfg(feature = "zlib")]
(false, InnerBody::Zlib(_)) => {
let mut hint = SizeHint::default();
hint.set_lower(1);
hint.set_upper(self.full_size + 256);
Expand Down Expand Up @@ -267,16 +282,7 @@ impl EncodeResponse for Response<Body> {
*enc = new;
return self;
}
Body {
inner:
InnerBody::Brotli(_)
| InnerBody::Zlib(_)
| InnerBody::Gzip(_)
| InnerBody::Hyper(_)
| InnerBody::Lazy { .. }
| InnerBody::Streaming(_),
..
} => return self,
Body { .. } => return self,

Check warning on line 285 in mendes/src/body.rs

View check run for this annotation

Codecov / codecov/patch

mendes/src/body.rs#L285

Added line #L285 was not covered by tests
};

let len = buf.len();
Expand Down

0 comments on commit d2035be

Please sign in to comment.