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