Skip to main content

FetchWith

Trait FetchWith 

Source
pub trait FetchWith {
    // Required method
    fn fetch_with<T>(
        &self,
        client: T,
    ) -> impl Future<Output = Result<DeboaResponse>>
       where T: AsRef<Client> + Send;
}
Expand description

Trait to allow make a get request from different types.

§Examples

use deboa::{Deboa, request::FetchWith};

let client = Deboa::default();

let response = "https://jsonplaceholder.typicode.com"
  .fetch_with(&client)
  .await?;
assert_eq!(response.status(), 200);

Required Methods§

Source

fn fetch_with<T>( &self, client: T, ) -> impl Future<Output = Result<DeboaResponse>>
where T: AsRef<Client> + Send,

Fetch the request.

§Returns
  • Result<DeboaResponse> - The response.
§Examples
use deboa::{Client, request::FetchWith};

let client = Client::new();

let response = "https://jsonplaceholder.typicode.com"
  .fetch_with(&client)
  .await?;
assert_eq!(response.status(), 200);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FetchWith for &str

Source§

async fn fetch_with<T>(&self, client: T) -> Result<DeboaResponse>
where T: AsRef<Client> + Send,

Source§

impl FetchWith for String

Source§

async fn fetch_with<T>(&self, client: T) -> Result<DeboaResponse>
where T: AsRef<Client> + Send,

Implementors§