pub struct FetchedResponse<'a> {
pub status: u16,
pub headers: HashMap<String, String>,
/* private fields */
}Expand description
A response fetched via route.fetch().
Fields§
§status: u16HTTP status code.
headers: HashMap<String, String>Response headers.
Implementations§
Source§impl FetchedResponse<'_>
impl FetchedResponse<'_>
Sourcepub fn body(&self) -> Result<Vec<u8>, NetworkError>
pub fn body(&self) -> Result<Vec<u8>, NetworkError>
Get the response body.
The body is fetched when route.fetch() is called, so this method
returns immediately.
Sourcepub fn text(&self) -> Result<String, NetworkError>
pub fn text(&self) -> Result<String, NetworkError>
Get the response body as text.
Sourcepub fn json<T: DeserializeOwned>(&self) -> Result<T, NetworkError>
pub fn json<T: DeserializeOwned>(&self) -> Result<T, NetworkError>
Parse the response body as JSON.
Sourcepub async fn fulfill(self) -> Result<(), NetworkError>
pub async fn fulfill(self) -> Result<(), NetworkError>
Continue the response to the page.
This must be called after inspecting/modifying the response to let the browser receive it.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for FetchedResponse<'a>
impl<'a> !RefUnwindSafe for FetchedResponse<'a>
impl<'a> Send for FetchedResponse<'a>
impl<'a> Sync for FetchedResponse<'a>
impl<'a> Unpin for FetchedResponse<'a>
impl<'a> !UnwindSafe for FetchedResponse<'a>
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