Crate ipzone

Source
Expand description

§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]));

Modules§

ip
port
prelude