Request

Trait Request 

Source
pub trait Request: Send + Sync {
    type Response: Response;

    // Required methods
    fn new() -> Self
       where Self: Sized;
    fn get(
        &self,
        url: &str,
    ) -> impl Future<Output = Result<Self::Response>> + Send;
    fn post(
        &self,
        url: &str,
        body: &str,
    ) -> impl Future<Output = Result<Self::Response>> + Send;
}
Expand description

Trait for HTTP clients that can make requests to the polygon.io API.

Implement this trait to use custom HTTP clients with the polygon.io client.

Required Associated Types§

Source

type Response: Response

Associated response type

Required Methods§

Source

fn new() -> Self
where Self: Sized,

Create a new instance of the HTTP client

Source

fn get(&self, url: &str) -> impl Future<Output = Result<Self::Response>> + Send

Make an HTTP GET request to the given URL

Source

fn post( &self, url: &str, body: &str, ) -> impl Future<Output = Result<Self::Response>> + Send

Make an HTTP POST request to the given URL with a JSON body

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 Request for Client

Available on crate feature reqwest only.
Source§

type Response = HttpResponse

Source§

fn new() -> Self

Source§

async fn get(&self, url: &str) -> Result<Self::Response>

Source§

async fn post(&self, url: &str, body: &str) -> Result<Self::Response>

Implementors§