Skip to main content

ClientExt

Trait ClientExt 

Source
pub trait ClientExt {
    // Required methods
    fn post_form_as_json<T, F>(
        &self,
        url: &str,
        form: &F,
    ) -> impl Future<Output = Result<T>> + Send
       where T: DeserializeOwned + Debug,
             F: Serialize + Sync + ?Sized;
    fn post_json_as_json<T, J>(
        &self,
        url: &str,
        json: &J,
    ) -> impl Future<Output = Result<T>> + Send
       where T: DeserializeOwned + Debug,
             J: Serialize + Sync + ?Sized;
    fn post_json_as_text<J>(
        &self,
        url: &str,
        json: &J,
    ) -> impl Future<Output = Result<String>> + Send
       where J: Serialize + Sync + ?Sized;
    fn fetch_as_text(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<String>> + Send;
    fn fetch_as_json<T: DeserializeOwned + Debug>(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<T>> + Send;
    fn patch_json_as_json<T, J>(
        &self,
        url: &str,
        json: &J,
    ) -> impl Future<Output = Result<T>> + Send
       where T: DeserializeOwned + Debug,
             J: Serialize + Sync + ?Sized;
    fn patch_json_as_text<J>(
        &self,
        url: &str,
        json: &J,
    ) -> impl Future<Output = Result<String>> + Send
       where J: Serialize + Sync + ?Sized;
}

Required Methods§

Source

fn post_form_as_json<T, F>( &self, url: &str, form: &F, ) -> impl Future<Output = Result<T>> + Send

Posts data to the given URL and deserializes the response as JSON.

§Errors

Returns an [Error] if:

  • A network request fails.
  • The response cannot be deserialized into the target type T.
  • An invalid URL is provided (though reqwest usually handles this during post).
Source

fn post_json_as_json<T, J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<T>> + Send

Posts JSON data to the given URL and deserializes the response as JSON.

§Errors

Returns an [Error] if:

  • A network request fails.
  • The response cannot be deserialized into the target type T.
  • An invalid URL is provided (though reqwest usually handles this during post).
Source

fn post_json_as_text<J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<String>> + Send
where J: Serialize + Sync + ?Sized,

Posts JSON data to the given URL returns the response body as a string.

§Errors

Returns an [Error] if:

  • A network request fails.
  • An invalid URL is provided (though reqwest usually handles this during post).
Source

fn fetch_as_text( &self, url: &str, ) -> impl Future<Output = Result<String>> + Send

Fetches data from the given URL and returns the response body as a string.

§Errors

Returns an [Error] if:

  • A network request fails.
  • The response body cannot be read as a string.
  • An invalid URL is provided (though reqwest usually handles this during get).
Source

fn fetch_as_json<T: DeserializeOwned + Debug>( &self, url: &str, ) -> impl Future<Output = Result<T>> + Send

Fetches data from the given URL and deserializes it as JSON.

§Errors

Returns an [Error] if:

  • A network request fails.
  • The response cannot be deserialized into the target type T.
  • An invalid URL is provided (though reqwest usually handles this during get).
Source

fn patch_json_as_json<T, J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<T>> + Send

Source

fn patch_json_as_text<J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<String>> + Send
where J: Serialize + Sync + ?Sized,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§