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
Enums
Constants
ALL
dns-resolver
or http-resolver
All builtin resolvers.
Traits
Trait implemented by IP address resolver.
Functions
addr
dns-resolver
or http-resolver
Attempts to produce an IP address with all builtin resolvers (best effort).
addr_v4
dns-resolver
or http-resolver
Attempts to produce an IPv4 address with all builtin resolvers (best effort).
addr_v6
dns-resolver
or http-resolver
Attempts to produce an IPv6 address with all builtin resolvers (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>
.