Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn protocol(&self) -> Protocol;
    fn get_ip(
        &self,
        version: IpVersion,
    ) -> Pin<Box<dyn Future<Output = Result<IpAddr, ProviderError>> + Send + '_>>;

    // Provided methods
    fn supports_v4(&self) -> bool { ... }
    fn supports_v6(&self) -> bool { ... }
    fn supports_version(&self, version: IpVersion) -> bool { ... }
}
Expand description

Trait for asynchronous IP detection providers

Required Methods§

Source

fn name(&self) -> &str

Provider name for identification

Source

fn protocol(&self) -> Protocol

Protocol used by this provider

Source

fn get_ip( &self, version: IpVersion, ) -> Pin<Box<dyn Future<Output = Result<IpAddr, ProviderError>> + Send + '_>>

Get the public IP address asynchronously

Provided Methods§

Source

fn supports_v4(&self) -> bool

Whether this provider supports IPv4

Source

fn supports_v6(&self) -> bool

Whether this provider supports IPv6

Source

fn supports_version(&self, version: IpVersion) -> bool

Check if provider supports the given IP version

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Provider for DnsProvider

Available on crate feature tokio only.
Source§

impl Provider for HttpProvider

Available on crate feature tokio only.
Source§

impl Provider for StunProvider

Available on crate feature tokio only.