std-type
Ipv4Addr: four-byte IP address
Represent an IPv4 address as four octets, independently of any port or network connection. Documentation addresses are used only as values in this example. Expected stdout (not executed): 192.0.2.7 [192, 0, 2, 7] Common mistake: Storing a port inside an IP address.
Formal Syntax & Structure
rust syntaxrust
Ipv4Addr::new(a: u8, b: u8, c: u8, d: u8)Working Example
Example Snippetrust
fn main() { use std::net::Ipv4Addr; let ip = Ipv4Addr::new(192, 0, 2, 7); println!("{} {:?}", ip, ip.octets());}