Skip to main content

AsyncIpApi

Trait AsyncIpApi 

Source
pub trait AsyncIpApi: IpApi {
    // Required methods
    fn query_api_default(
        &self,
        ip: &str,
    ) -> impl Future<Output = Result<IpDefaultResponse, IpApiError>> + Send;
    fn query_api_fully(
        &self,
        ip: &str,
    ) -> impl Future<Output = Result<IpFullResponse, IpApiError>> + Send;
    fn query_api<T>(
        &self,
        ip: &str,
    ) -> impl Future<Output = Result<T, IpApiError>> + Send
       where T: DeserializeOwned;
    fn get_http_client(&self) -> &Client;
}
Expand description

The async client for the ip-api.com API.

Required Methods§

Source

fn query_api_default( &self, ip: &str, ) -> impl Future<Output = Result<IpDefaultResponse, IpApiError>> + Send

Queries the API with the default fields.

§Arguments
  • ip - The IP address to query.
§Returns
  • IpDefaultResponse - The response from the API.
Source

fn query_api_fully( &self, ip: &str, ) -> impl Future<Output = Result<IpFullResponse, IpApiError>> + Send

Queries the API with all fields.

§Arguments
  • ip - The IP address to query.
§Returns
  • IpFullResponse - The response from the API.
Source

fn query_api<T>( &self, ip: &str, ) -> impl Future<Output = Result<T, IpApiError>> + Send

Queries the API with a custom struct.

§Arguments
  • ip - The IP address to query.
  • T - The custom struct to deserialize the response into.
§Returns
  • T - The response from the API.
Source

fn get_http_client(&self) -> &Client

Gets you the async http client.

§Returns
  • &reqwest::Client - The async http client.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§