[][src]Struct seed::browser::fetch::Response

pub struct Response { /* fields omitted */ }

Response of the fetch request. To get one you need to use fetch function.

MDN reference

Implementations

impl Response[src]

pub async fn text<'_>(&'_ self) -> Result<String>[src]

Get a String from response body.

Errors

Returns FetchError::PromiseError.

pub async fn json<'_, T: DeserializeOwned + 'static>(&'_ self) -> Result<T>[src]

JSON parse response body into provided type.

Errors

Returns FetchError::SerdeError or FetchError::PromiseError.

pub async fn bytes<'_>(&'_ self) -> Result<Vec<u8>>[src]

Return response body as Vec<u8>.

Errors

Returns FetchError::PromiseError.

pub fn status(&self) -> Status[src]

Get request status.

pub fn check_status(self) -> Result<Self>[src]

Check that response status is ok (2xx).

fetch(url).await?.check_status()?

Or with combinators:

fetch(url)
    .map(|result| result.and_then(Response::check_status))
    .and_then(Response.json)
    .map(Msg::Fetched)

Errors

Returns FetchError::StatusError if status isn't 2xx.

pub const fn raw_response(&self) -> &Response[src]

Get underlying web_sys::Response.

This is an escape path if current API can't handle your needs. Should you find yourself using it, please consider opening an issue.

Auto Trait Implementations

impl RefUnwindSafe for Response

impl !Send for Response

impl !Sync for Response

impl Unpin for Response

impl UnwindSafe for Response

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Sealed<T> for T where
    T: ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,