ipzone

Crates.ioipzone
lib.rsipzone
version0.4.0
sourcesrc
created_at2022-12-06 20:11:21.224046
updated_at2022-12-10 04:45:43.398892
descriptionIpzone provides a simple and powerful IP architecture to Rust.
homepagehttps://github.com/just-do-halee/ipzone
repositoryhttps://github.com/just-do-halee/ipzone.git
max_upload_size
id731402
size30,383
Doha Lee (just-do-halee)

documentation

https://docs.rs/ipzone

README

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]));
Commit count: 12

cargo fmt