Crates.io | ipzone |
lib.rs | ipzone |
version | 0.4.0 |
source | src |
created_at | 2022-12-06 20:11:21.224046 |
updated_at | 2022-12-10 04:45:43.398892 |
description | Ipzone provides a simple and powerful IP architecture to Rust. |
homepage | https://github.com/just-do-halee/ipzone |
repository | https://github.com/just-do-halee/ipzone.git |
max_upload_size | |
id | 731402 |
size | 30,383 |
ipzone
Ipzone provides a simple and powerful IP architecture to Rust.
| 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]));