Crate public_ip[][src]

Expand description

Crate for resolving a devices’ own public IP address.

#[tokio::main]
async fn main() {
    // Attempt to get an IP address and print it.
    if let Some(ip) = public_ip::addr().await {
        println!("public ip address: {:?}", ip);
    } else {
        println!("couldn't get an IP address");
    }
}

Modules

dnsdns-resolver

DNS resolver support.

httphttp-resolver

HTTP resolver support.

Enums

An error produced while attempting to resolve.

The version of IP address to resolve.

Constants

ALLdns-resolver or http-resolver

All builtin resolvers.

Traits

Trait implemented by IP address resolver.

Functions

addrdns-resolver or http-resolver

Attempts to produce an IP address with all builtin resolvers (best effort).

addr_v4dns-resolver or http-resolver

Attempts to produce an IPv4 address with all builtin resolvers (best effort).

addr_v6dns-resolver or http-resolver

Attempts to produce an IPv6 address with all builtin resolvers (best effort).

Given a Resolver and requested Version, attempts to produce an IP address (best effort).

Given a Resolver and requested Version, attempts to produce an IP address along with the details of how it was resolved (best effort).

Given a Resolver and requested Version, produces a stream of Resolutions.

Type Definitions

The details of a resolution.

A Stream of Result<(IpAddr, Details), Error>.