aws_smithy_compression/
http.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6//! Checksum support for HTTP requests and responses.
7
8/// Support for the `http-body-1-0` and `http-1-0` crates.
9use crate::Compress;
10use http_1x::header::{HeaderName, HeaderValue};
11
12/// Implementors of this trait can be used to compress HTTP requests.
13pub trait CompressRequest: Compress + CloneCompressRequest {
14    /// Return the header name for the content-encoding header.
15    fn header_name(&self) -> HeaderName {
16        HeaderName::from_static("content-encoding")
17    }
18
19    /// Return the header value for the content-encoding header.
20    fn header_value(&self) -> HeaderValue;
21}
22
23/// Enables CompressRequest implementors to be cloned.
24pub trait CloneCompressRequest {
25    /// Clone this request compressor.
26    fn clone_request_compressor(&self) -> Box<dyn CompressRequest>;
27}
28
29impl<T> CloneCompressRequest for T
30where
31    T: CompressRequest + Clone + 'static,
32{
33    fn clone_request_compressor(&self) -> Box<dyn CompressRequest> {
34        Box::new(self.clone())
35    }
36}
37
38impl Clone for Box<dyn CompressRequest> {
39    fn clone(&self) -> Self {
40        self.clone_request_compressor()
41    }
42}