[][src]Struct seed::browser::service::fetch::Request

pub struct Request { /* fields omitted */ }
👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Request is the entry point for all fetch requests. Its methods configure the request, and handle the response. Many of them return the original struct, and are intended to be used chained together.

Implementations

impl Request[src]

pub fn new(url: impl Into<Cow<'static, str>>) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub const fn method(self, method: Method) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Set the HTTP method. Default is GET.

MDN reference

pub fn header(self, name: &str, value: &str) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Add a single header. String multiple calls to this together to add multiple ones.

MDN reference

pub fn body(self, body: JsValue) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub fn body_json<T: Serialize>(self, body_json: &T) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Serialize a Rust data structure as JSON; eg the payload in a POST request. Note: If you want to setup Content-Type header automatically, use method send_json.

pub fn send_json<T: Serialize>(self, data: &T) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Set body to serialized data and set header Content-Type to application/json; charset=utf-8.

pub const fn cache(self, cache: RequestCache) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub const fn credentials(self, request_credentials: RequestCredentials) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub fn integrity(self, integrity: &str) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub const fn mode(self, mode: RequestMode) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub const fn redirect(self, redirect: RequestRedirect) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub fn referrer(self, referrer: String) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub const fn referrer_policy(self, referrer_policy: ReferrerPolicy) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

pub const fn timeout(self, millis: u32) -> Self[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Enable request timeout and set it to given milliseconds.

pub fn controller(
    self,
    controller_transferrer: impl FnOnce(RequestController)
) -> Self
[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Get request controller through callback function. You can use controller to abort request or disable timeout.

Example

fn send_request(
   request_controller: &mut Option<fetch::RequestController>
) -> impl Future<Item=Msg, Error=Msg> {
   fetch::Request::new(get_request_url())
       .controller(|controller| *request_controller = Some(controller))
       .fetch_string(Msg::Fetched)
}

pub async fn fetch<U>(self, f: impl FnOnce(FetchObject<()>) -> U) -> U where
    U: 'static, 
[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Fetch.

It never fails. Use callback f to map FetchObject<()>. E.g.: You can use std::convert::identity as f to return Result<FetchObject<()>, FetchObject<()>.

It's lazy - fetching is started when Future is executed.

It always set FetchObject.result->ResponseWithDataResult field data to Ok(()) - if you want to get body data, you have to use field raw to get raw web_sys::Response. (Or use methods like fetch_string / fetch_json.)

MDN reference

Example

async fn send_request() -> Result<Msg, Msg> {
   fetch::Request::new(get_request_url())
       .fetch(Msg::Fetched)
       .await
}

pub async fn fetch_string<U>(
    self,
    f: impl FnOnce(FetchObject<String>) -> U
) -> U where
    U: 'static, 
[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Same as method fetch, but try to convert body to String and insert it into Response field data. [MDN reference](https://developer.mozilla.org/en-US/docs/Web/API/Body/text]

pub fn fetch_string_data<U>(
    self,
    f: impl FnOnce(ResponseDataResult<String>) -> U
) -> impl Future<Output = U> where
    U: 'static, 
[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Fetch and then convert body to String. It passes ResponseDataResult<String> into callback f. MDN reference

pub async fn fetch_json<T, U>(self, f: impl FnOnce(FetchObject<T>) -> U) -> U where
    T: DeserializeOwned + 'static,
    U: 'static, 
[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Same as method fetch, but try to deserialize body and insert it into Response field data.

pub fn fetch_json_data<T, U>(
    self,
    f: impl FnOnce(ResponseDataResult<T>) -> U
) -> impl Future<Output = U> where
    T: DeserializeOwned + 'static,
    U: 'static, 
[src]

👎 Deprecated since 0.7.0:

Please use seed::browser::fetch module instead

Fetch and then deserialize body to T. It passes ResponseDataResult<T> into callback f.

Trait Implementations

impl Clone for Request[src]

impl Debug for Request[src]

impl Default for Request[src]

Auto Trait Implementations

impl !RefUnwindSafe for Request

impl !Send for Request

impl !Sync for Request

impl Unpin for Request

impl !UnwindSafe for Request

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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>,