66 66 | }
|
67 67 |
|
68 68 | /// Returns the signable body
|
69 69 | pub fn body(&self) -> &SignableBody<'_> {
|
70 70 | &self.body
|
71 71 | }
|
72 72 | }
|
73 73 |
|
74 74 | /// A signable HTTP request body
|
75 75 | #[derive(Debug, Clone, Eq, PartialEq)]
|
76 76 | #[non_exhaustive]
|
77 77 | pub enum SignableBody<'a> {
|
78 78 | /// A body composed of a slice of bytes
|
79 79 | Bytes(&'a [u8]),
|
80 80 |
|
81 81 | /// An unsigned payload
|
82 82 | ///
|
83 83 | /// UnsignedPayload is used for streaming requests where the contents of the body cannot be
|
84 84 | /// known prior to signing
|
85 85 | UnsignedPayload,
|
86 86 |
|
87 87 | /// A precomputed body checksum. The checksum should be a SHA256 checksum of the body,
|
88 88 | /// lowercase hex encoded. Eg:
|
89 89 | /// `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`
|
90 90 | Precomputed(String),
|
91 91 |
|
92 92 | /// Set when a streaming body has checksum trailers.
|
93 93 | StreamingUnsignedPayloadTrailer,
|
94 94 | }
|
95 95 |
|
96 - | impl SignableBody<'_> {
|
97 - | /// Create a new empty signable body
|
98 - | pub fn empty() -> SignableBody<'static> {
|
99 - | SignableBody::Bytes(&[])
|
100 - | }
|
101 - | }
|
102 - |
|
103 96 | /// Instructions for applying a signature to an HTTP request.
|
104 97 | #[derive(Debug)]
|
105 98 | pub struct SigningInstructions {
|
106 99 | headers: Vec<Header>,
|
107 100 | params: Vec<(&'static str, Cow<'static, str>)>,
|
108 101 | }
|
109 102 |
|
110 103 | /// Header representation for use in [`SigningInstructions`]
|
111 104 | pub struct Header {
|
112 105 | key: &'static str,
|