pub struct IPWhoClient { /* private fields */ }Expand description
Rust client for the IPWho IP Geolocation API.
Implementations§
Source§impl IPWhoClient
impl IPWhoClient
Sourcepub fn new<S: Into<String>>(api_key: S) -> Result<Self, IpWhoError>
pub fn new<S: Into<String>>(api_key: S) -> Result<Self, IpWhoError>
Create a new client with the given API key.
api_key is required by the API as the apiKey query parameter.
Sourcepub fn with_client<S: Into<String>>(
api_key: S,
http: Client,
base_url: Url,
) -> Self
pub fn with_client<S: Into<String>>( api_key: S, http: Client, base_url: Url, ) -> Self
Create a new client with a custom HTTP client and base URL.
Sourcepub async fn lookup(
&self,
ip: &str,
format: Option<&str>,
fields: Option<&str>,
) -> Result<IpGeoResponse, IpWhoError>
pub async fn lookup( &self, ip: &str, format: Option<&str>, fields: Option<&str>, ) -> Result<IpGeoResponse, IpWhoError>
Look up geolocation data for a specific IP address.
ip: IPv4 or IPv6 address.format: Response format ("json","xml","csv"). Default is"json".fields: Optional comma-separated field filter (e.g."geoLocation,timezone").
Sourcepub async fn me(
&self,
format: Option<&str>,
fields: Option<&str>,
) -> Result<IpGeoResponse, IpWhoError>
pub async fn me( &self, format: Option<&str>, fields: Option<&str>, ) -> Result<IpGeoResponse, IpWhoError>
Look up geolocation data for the caller’s own IP address.
format: Response format.fields: Optional comma-separated field filter.
Sourcepub async fn bulk(&self, ips: &[&str]) -> Result<BulkResponse, IpWhoError>
pub async fn bulk(&self, ips: &[&str]) -> Result<BulkResponse, IpWhoError>
Perform a bulk IP lookup.
ips: Slice of IPv4/IPv6 addresses.
Trait Implementations§
Source§impl Clone for IPWhoClient
impl Clone for IPWhoClient
Source§fn clone(&self) -> IPWhoClient
fn clone(&self) -> IPWhoClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for IPWhoClient
impl !UnwindSafe for IPWhoClient
impl Freeze for IPWhoClient
impl Send for IPWhoClient
impl Sync for IPWhoClient
impl Unpin for IPWhoClient
impl UnsafeUnpin for IPWhoClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more