std-method

IP address classification

Classify an address by its defined purpose. Loopback refers to the same host, unspecified addresses may be used for binding, and multicast addresses denote groups. Classification alone cannot establish trust or reachability. Expected stdout (not executed): true false false false true false false false true Common mistake: Using a private or loopback address classification as proof of authorization.

Formal Syntax & Structure

rust syntaxrust
ip.is_loopback(); ip.is_unspecified(); ip.is_multicast()

Working Example

Example Snippetrust
fn main() {    use std::net::IpAddr;    for text in ["127.0.0.1", "::", "ff02::1"] {        let ip: IpAddr = text.parse().unwrap();        println!("{} {} {}", ip.is_loopback(), ip.is_unspecified(), ip.is_multicast());    }}
Rust Reference