pub struct Response<B = EmptyBody> {
pub metadata: ResponseMetadata,
pub body: B,
}Fields§
§metadata: ResponseMetadata§body: BImplementations§
Source§impl<B> Response<B>
impl<B> Response<B>
pub fn new(status: Status, body: B) -> Self
pub fn from_parts(metadata: ResponseMetadata, body: B) -> Self
pub fn into_parts(self) -> (ResponseMetadata, B)
Source§impl<B: ReadableBody> Response<B>
impl<B: ReadableBody> Response<B>
Sourcepub fn length(&self) -> Option<u64>
pub fn length(&self) -> Option<u64>
The length of the data this response sends: the body’s own length when it knows one, because the body is what is sent, and otherwise the declaration ResponseMetadata::declared_length keeps. A response without data, to HEAD or with 204 or 304, is instead described by content_length, and a tunnel has no length.
Methods from Deref<Target = ResponseMetadata>§
Sourcepub fn declared_length(&self, body: Option<u64>) -> Option<u64>
pub fn declared_length(&self, body: Option<u64>) -> Option<u64>
The declared content_length, unless a body of the given known length contradicts it, as after replacing the body. A codec sending this response’s data uses it; a response without data, to HEAD or with 204 or 304, is described by content_length itself, so every protocol resolves the same length.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for Response<B>where
B: Freeze,
impl<B> RefUnwindSafe for Response<B>where
B: RefUnwindSafe,
impl<B> Send for Response<B>where
B: Send,
impl<B> Sync for Response<B>where
B: Sync,
impl<B> Unpin for Response<B>where
B: Unpin,
impl<B> UnsafeUnpin for Response<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for Response<B>where
B: 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
Mutably borrows from an owned value. Read more