#[non_exhaustive]pub struct Parts {
pub headers: HeaderMap<HeaderValue>,
}Expand description
Component parts of a response.
The response parts, other than the body, consist of just headers. We anticipate the addition of new fields over time.
The headers are used to return gRPC metadata, as well as (unsurprisingly) HTTP headers.
§Example
let mut headers = http::HeaderMap::new();
headers.insert(http::header::CONTENT_TYPE, http::HeaderValue::from_static("application/json"));
let parts = Parts::new().set_headers(headers);
assert_eq!(
parts.headers.get(http::header::CONTENT_TYPE),
Some(&http::HeaderValue::from_static("application/json"))
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.headers: HeaderMap<HeaderValue>The HTTP headers or the gRPC metadata converted to HTTP headers.
Implementations§
Source§impl Parts
impl Parts
Sourcepub fn set_headers<V>(self, v: V) -> Self
pub fn set_headers<V>(self, v: V) -> Self
Set the headers.
§Example
let mut headers = http::HeaderMap::new();
headers.insert(
http::header::CONTENT_TYPE,
http::HeaderValue::from_static("application/json"),
);
let parts = Parts::new().set_headers(headers.clone());
assert_eq!(parts.headers, headers);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parts
impl RefUnwindSafe for Parts
impl Send for Parts
impl Sync for Parts
impl Unpin for Parts
impl UnwindSafe for Parts
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
Mutably borrows from an owned value. Read more