Struct SigningRequest
pub struct SigningRequest {
pub method: Method,
pub scheme: Scheme,
pub authority: Authority,
pub path: String,
pub query: Vec<(String, String)>,
pub headers: HeaderMap,
}reqsign only.Expand description
A service-local canonicalization view and signed-header staging area.
The method and URI-derived fields are read-only working values. They do not own
the wire URI and must not be mutated to express signing output. The URI supplied
to Self::build is already the final caller-provided representation; services
derive canonical values locally and construct query authentication from the
original URI.
Fields§
§method: MethodRead-only HTTP method used for canonicalization.
scheme: SchemeRead-only HTTP scheme used for canonicalization.
Read-only HTTP authority used for canonicalization.
path: StringRead-only, percent-encoded wire path.
Services may derive a canonical path from this value, but must not decode it and write the result back to the request URI.
query: Vec<(String, String)>HTTP query parameters decoded once from the wire query for canonicalization.
Percent escapes are decoded once, literal + remains +, and duplicate order
is retained. This working view does not own or rebuild the wire URI.
headers: HeaderMapStaged HTTP headers committed by Self::apply.
Implementations§
§impl SigningRequest
impl SigningRequest
pub fn build(parts: &mut Parts) -> Result<SigningRequest, Error>
pub fn build(parts: &mut Parts) -> Result<SigningRequest, Error>
Build a read-only request-target working view from http::request::Parts.
The URI path and query must already be percent-encoded for transport, and the URI must contain an authority. This method clones the URI-derived values and headers; the input request head remains unchanged on success or error.
pub fn apply(self, parts: &mut Parts) -> Result<(), Error>
pub fn apply(self, parts: &mut Parts) -> Result<(), Error>
Commit staged headers back to http::request::Parts.
In debug builds, this method verifies that the method, scheme, authority, path,
and decoded query working view still match parts. A mismatch returns an error
without changing parts. Release builds omit this implementation check.
On success, only headers are committed. This method never writes the method or URI. Query signers must construct their final URI from the original wire URI and assign it separately after all fallible signing work succeeds.
pub fn path_percent_decoded(&self) -> Cow<'_, str>
pub fn path_percent_decoded(&self) -> Cow<'_, str>
Return the entire working path percent-decoded.
This is a canonicalization helper, not a wire URI builder. Decoding the entire
path turns encoded slashes such as %2F into /; services where encoded slash
is data must decode path segments separately.
pub fn query_size(&self) -> usize
pub fn query_size(&self) -> usize
Return the combined key and value length of the decoded working query.
This is not the byte length of the wire query.
pub fn query_push(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn query_push(&mut self, key: impl Into<String>, value: impl Into<String>)
Push a new query pair into the working query view.
This does not modify the wire URI. Self::apply rejects a modified
request-target view in debug builds and ignores it in release builds. Query
signers must construct their final URI from the original wire URI instead.
pub fn query_append(&mut self, query: &str)
pub fn query_append(&mut self, query: &str)
Push a query string into the working query view.
This does not modify the wire URI; see Self::query_push.
pub fn query_to_vec_with_filter(
&self,
filter: impl Fn(&str) -> bool,
) -> Vec<(String, String)>
pub fn query_to_vec_with_filter( &self, filter: impl Fn(&str) -> bool, ) -> Vec<(String, String)>
Clone working query pairs whose keys match a canonicalization filter.
pub fn query_to_string(
query: Vec<(String, String)>,
sep: &str,
join: &str,
) -> String
pub fn query_to_string( query: Vec<(String, String)>, sep: &str, join: &str, ) -> String
Convert sorted query pairs to a canonical string.
This helper does not produce or modify a wire URI.
[(a, b), (c, d)] => "a:b\nc:d"pub fn query_to_percent_decoded_string(
query: Vec<(String, String)>,
sep: &str,
join: &str,
) -> String
pub fn query_to_percent_decoded_string( query: Vec<(String, String)>, sep: &str, join: &str, ) -> String
Convert sorted query pairs to a string after percent-decoding each value.
Values from Self::query have already been decoded once. Passing them to
this helper performs an additional decode and is only correct when a service
protocol explicitly requires it. This helper does not produce a wire URI.
[(a, b), (c, d)] => "a:b\nc:d"pub fn header_get_or_default(&self, key: &HeaderName) -> Result<&str, Error>
pub fn header_get_or_default(&self, key: &HeaderName) -> Result<&str, Error>
Get header value by name.
Returns empty string if header not found.
pub fn header_value_normalize(v: &mut HeaderValue)
pub fn header_value_normalize(v: &mut HeaderValue)
Normalize a header value for canonicalization.
Normalize a clone when the protocol does not require changing the wire header;
mutating a value inside Self::headers changes the header committed by
Self::apply.
pub fn header_name_to_vec_sorted(&self) -> Vec<&str>
pub fn header_name_to_vec_sorted(&self) -> Vec<&str>
Get header names as sorted vector.
pub fn header_to_vec_with_prefix(&self, prefix: &str) -> Vec<(String, String)>
pub fn header_to_vec_with_prefix(&self, prefix: &str) -> Vec<(String, String)>
Get header names with given prefix.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SigningRequest
impl RefUnwindSafe for SigningRequest
impl Send for SigningRequest
impl Sync for SigningRequest
impl Unpin for SigningRequest
impl UnsafeUnpin for SigningRequest
impl UnwindSafe for SigningRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<E> ResultError for E
§impl<T> Scope for T
impl<T> Scope for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.