#[non_exhaustive]pub struct FetchResponse {
pub url: Url,
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Bytes,
}Expand description
A response, loosely https://fetch.spec.whatwg.org/#responses.
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.url: UrlThe URL the response actually came from, after any redirects.
Not the requested URL. A guest resolving relative links out of a response body needs the one it landed on.
status: StatusCode§headers: HeaderMap§body: BytesImplementations§
Source§impl FetchResponse
impl FetchResponse
Sourcepub fn new(url: Url, status: StatusCode) -> Self
pub fn new(url: Url, status: StatusCode) -> Self
A response with the given status and no headers or body.
A constructor rather than a struct literal because the type is
#[non_exhaustive], and it is #[non_exhaustive] because every
provider lives outside this crate: a field added here later would
otherwise break all of them at once. Build with this and the setters,
and a new field arrives with a default instead of a compile error.
pub fn headers(self, headers: HeaderMap) -> Self
pub fn body(self, body: Bytes) -> Self
Trait Implementations§
Source§impl Clone for FetchResponse
impl Clone for FetchResponse
Auto Trait Implementations§
impl !Freeze for FetchResponse
impl RefUnwindSafe for FetchResponse
impl Send for FetchResponse
impl Sync for FetchResponse
impl Unpin for FetchResponse
impl UnsafeUnpin for FetchResponse
impl UnwindSafe for FetchResponse
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