pub struct TypedResponse<Output> {
pub value: Output,
pub status: StatusCode,
pub headers: Vec<RuntimeHeader>,
}Expand description
A decoded typed body paired with the status and headers it arrived with (issue #493).
CratestackClient::{get,post,patch,delete} decode straight to
Output, discarding everything else about the response — which
makes an @version model’s optimistic-locking contract
unreachable through the typed surface: the required round trip is
GET → read ETag → PATCH with If-Match, and the middle step
needs a header that plain get throws away. TypedResponse exists
so a caller can opt into the metadata via the *_with_response
methods without touching the original signatures at all — every
existing call site keeps compiling unchanged.
Fields§
§value: Output§status: StatusCode§headers: Vec<RuntimeHeader>Implementations§
Source§impl<Output> TypedResponse<Output>
impl<Output> TypedResponse<Output>
Sourcepub fn header(&self, name: &str) -> Option<&str>
pub fn header(&self, name: &str) -> Option<&str>
Case-insensitive header lookup — HTTP header names are
case-insensitive per RFC 7230 §3.2, but RuntimeHeader stores
them as plain strings (the wire type is also used across the
FFI boundary, where a HeaderMap isn’t available), so a caller
doing .header("ETag") against a server that sent etag must
not silently miss it.
Returns only the first matching value. A header name may
legitimately repeat (e.g. multiple Set-Cookie lines) — this
method silently drops every value after the first, with no
signal that more exist. Every header this crate’s own docs
point callers at (ETag, Idempotency-Replayed, Retry-After)
is single-valued in practice, so this is a fine default, but a
caller who might be talking to a header that repeats should use
Self::header_values instead.
Sourcepub fn header_values<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a str>
pub fn header_values<'a>( &'a self, name: &'a str, ) -> impl Iterator<Item = &'a str>
Every value sent under name (case-insensitive), in the order
the server sent them — the honest counterpart to Self::header
for a header that may repeat (Set-Cookie being the canonical
example). Returns an empty iterator, not None, when name
wasn’t sent at all.
Trait Implementations§
Source§impl<Output: Clone> Clone for TypedResponse<Output>
impl<Output: Clone> Clone for TypedResponse<Output>
Source§fn clone(&self) -> TypedResponse<Output>
fn clone(&self) -> TypedResponse<Output>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Output: Debug> Debug for TypedResponse<Output>
impl<Output: Debug> Debug for TypedResponse<Output>
impl<Output: Eq> Eq for TypedResponse<Output>
Source§impl<Output: PartialEq> PartialEq for TypedResponse<Output>
impl<Output: PartialEq> PartialEq for TypedResponse<Output>
Source§fn eq(&self, other: &TypedResponse<Output>) -> bool
fn eq(&self, other: &TypedResponse<Output>) -> bool
self and other values to be equal, and is used by ==.impl<Output: PartialEq> StructuralPartialEq for TypedResponse<Output>
Auto Trait Implementations§
impl<Output> Freeze for TypedResponse<Output>where
Output: Freeze,
impl<Output> RefUnwindSafe for TypedResponse<Output>where
Output: RefUnwindSafe,
impl<Output> Send for TypedResponse<Output>where
Output: Send,
impl<Output> Sync for TypedResponse<Output>where
Output: Sync,
impl<Output> Unpin for TypedResponse<Output>where
Output: Unpin,
impl<Output> UnsafeUnpin for TypedResponse<Output>where
Output: UnsafeUnpin,
impl<Output> UnwindSafe for TypedResponse<Output>where
Output: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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