#ip #address #addr #net #networking

ipzone

Ipzone provides a simple and powerful IP architecture to Rust

4 releases (breaking)

0.4.0 Dec 10, 2022
0.3.0 Dec 8, 2022
0.2.0 Dec 7, 2022
0.1.0 Dec 6, 2022

#3 in #addr

MIT/Apache

10KB
189 lines

ipzone

Ipzone provides a simple and powerful IP architecture to Rust.

CI Crates.io Licensed Twitter

| Examples | Docs | Latest Note |

ipzone = "0.4.0"

Examples

use ipzone::prelude::*;

let local: Address<3> = ip::localhost([6004, 7040, 8080]);
TcpListener::bind(local);

let address: Address<2> = ip::from([168, 159, 42, 9]).with([80, 443]);
TcpStream::connect(address);

let local = ip::localhost([port::from_env("PORT").unwrap_or(8080), 7020, 2020]);
TcpListener::bind(local);

let address = ip::from([186, 23, 123, 1, 0, 0, 0, 0]).with([80, 443]);
TcpStream::connect(address);

let local = ip::localhost([1234, 5678, port::from_str("9090").unwrap());
TcpListener::bind(local);

let address = ip::from_str("168.24.41.123").unwrap().with([80, 443]);
TcpStream::connect(address);

let local = ip::from_str("::1").unwrap().with([80, 443]);
TcpListener::bind(local);

let address = ip::from_env("IP").unwrap().with([80, 443]);
TcpStream::connect(address);

static LOCALHOST: Global<Address> = global(|| ip::localhost().with([8080]));

Dependencies

~300–780KB
~18K SLoC