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
orhttp-resolver
- All builtin resolvers.
Traits§
- Resolver
- Trait implemented by IP address resolver.
Functions§
- addr
dns-resolver
orhttp-resolver
- Attempts to produce an IP address with all builtin resolvers (best effort).
- addr_v4
dns-resolver
orhttp-resolver
- Attempts to produce an IPv4 address with all builtin resolvers (best effort).
- addr_v6
dns-resolver
orhttp-resolver
- Attempts to produce an IPv6 address with all builtin resolvers (best effort).
- addr_
with - Given a
Resolver
and requestedVersion
, attempts to produce an IP address (best effort). - addr_
with_ details - Given a
Resolver
and requestedVersion
, attempts to produce an IP address along with the details of how it was resolved (best effort). - resolve
- Given a
Resolver
and requestedVersion
, produces a stream ofResolutions
.
Type Aliases§
- Details
- The details of a resolution.
- Resolutions
- A
Stream
ofResult<(IpAddr, Details), Error>
.