use super::Decompression;
use crate::headers::encoding::AcceptEncoding;
use rama_core::Layer;
#[derive(Debug, Default, Clone)]
pub struct DecompressionLayer {
accept: AcceptEncoding,
}
impl<S> Layer<S> for DecompressionLayer {
type Service = Decompression<S>;
fn layer(&self, service: S) -> Self::Service {
Decompression {
inner: service,
accept: self.accept,
}
}
}
impl DecompressionLayer {
pub fn new() -> Self {
Default::default()
}
pub fn gzip(mut self, enable: bool) -> Self {
self.accept.set_gzip(enable);
self
}
pub fn set_gzip(&mut self, enable: bool) -> &mut Self {
self.accept.set_gzip(enable);
self
}
pub fn deflate(mut self, enable: bool) -> Self {
self.accept.set_deflate(enable);
self
}
pub fn set_deflate(&mut self, enable: bool) -> &mut Self {
self.accept.set_deflate(enable);
self
}
pub fn br(mut self, enable: bool) -> Self {
self.accept.set_br(enable);
self
}
pub fn set_br(&mut self, enable: bool) -> &mut Self {
self.accept.set_br(enable);
self
}
pub fn zstd(mut self, enable: bool) -> Self {
self.accept.set_zstd(enable);
self
}
pub fn set_zstd(&mut self, enable: bool) -> &mut Self {
self.accept.set_zstd(enable);
self
}
}