s3s/
response.rs

1use hyper::HeaderMap;
2use hyper::http::Extensions;
3use hyper::http::HeaderValue;
4
5#[non_exhaustive]
6pub struct S3Response<T> {
7    /// Operation output
8    pub output: T,
9
10    /// Response headers, overrides the headers in `output`.
11    pub headers: HeaderMap<HeaderValue>,
12
13    /// Response extensions.
14    ///
15    /// It is used to pass custom data between middlewares.
16    pub extensions: Extensions,
17}
18
19impl<T> S3Response<T> {
20    pub fn new(output: T) -> Self {
21        Self {
22            output,
23            headers: HeaderMap::new(),
24            extensions: Extensions::new(),
25        }
26    }
27
28    pub fn with_headers(output: T, headers: HeaderMap<HeaderValue>) -> Self {
29        Self {
30            output,
31            headers,
32            extensions: Extensions::new(),
33        }
34    }
35
36    pub fn map_output<U>(self, f: impl FnOnce(T) -> U) -> S3Response<U> {
37        S3Response {
38            output: f(self.output),
39            headers: self.headers,
40            extensions: self.extensions,
41        }
42    }
43}