Expand description
ipzone
Ipzone provides a simple and powerful IP architecture to Rust.
| Examples | Docs | Latest Note |
ipzone = "0.1.0"Examples
use ipzone::prelude::*;
const LOCAL: Localhost<3> = Localhost([6004, 7040, 8080]);
// Localhost has implemented ToSocketAddrs trait so
// can server.bind(LOCAL);// From environment variables
let local = Localhost([6004, 7040, port::from_env!("PORT")]);
// unwrap_or(8080) version is port::from_env!("PORT", 8080)// From json files (features = "json")
// -- ../ports.json --
// [ 1234, 5678, 9101, 4321 ]
let local = Localhost(port::from_json!("../ports.json"; 4));
// can truncate it, port::from_json("../ports.json"; 2) = [ 1234, 5678 ]// Concatenating
let ports: [u16; 4] = port::concatn!(
[
[1234, port::from_env!("PORT")]
port::from_json!("../ports.json"; 2)
]
);
let local = Localhost(ports);