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§
Sourcefn post_form_as_json<T, F>(
&self,
url: &str,
form: &F,
) -> impl Future<Output = Result<T>> + Send
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
reqwestusually handles this duringpost).
Sourcefn post_json_as_json<T, J>(
&self,
url: &str,
json: &J,
) -> impl Future<Output = Result<T>> + Send
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
reqwestusually handles this duringpost).
Sourcefn post_json_as_text<J>(
&self,
url: &str,
json: &J,
) -> impl Future<Output = Result<String>> + Send
fn post_json_as_text<J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<String>> + Send
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
reqwestusually handles this duringpost).
Sourcefn fetch_as_text(
&self,
url: &str,
) -> impl Future<Output = Result<String>> + Send
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
reqwestusually handles this duringget).
Sourcefn fetch_as_json<T: DeserializeOwned + Debug>(
&self,
url: &str,
) -> impl Future<Output = Result<T>> + Send
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
reqwestusually handles this duringget).
fn patch_json_as_json<T, J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<T>> + Send
fn patch_json_as_text<J>( &self, url: &str, json: &J, ) -> impl Future<Output = Result<String>> + Send
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".