| Crates.io | fancy-ip |
| lib.rs | fancy-ip |
| version | 1.1.0 |
| created_at | 2023-05-23 12:41:59.041574+00 |
| updated_at | 2023-05-25 05:23:26.365137+00 |
| description | Fanciest way to initialize IP addresses |
| homepage | |
| repository | https://github.com/citorva/fancy-ip |
| max_upload_size | |
| id | 871986 |
| size | 23,284 |
Elegantly initialize IP and socket addresses.
Initializing IP address in the source code is currently not easy. It exists many
methods in the standard library such as using the parse function on a string
describing an IP address, which needs the use of time at the initialization for
generating the address and the need to have the code executed to check if the IP
is valid. Another way is using the IP and socket address constructor which is
heavy.
std contextsThis library can be used in place of parse and new calls. You can use this
library by simply add the following line in your Cargo.toml file:
fancy-ip = "1"
Then you have just to call fancy_ip::ipv4!() or fancy_ip::ipv6!() anywhere in
your source code. This library will automatically generate the constructor call
keeping your code clean and readable.
In the case of your IP address is malformed, the library will automatically print you the error.
no-std contextsThis library can also support the no-std context by simply calling the core
equivalent in your code.
Note that IP addresses in core is currently in early stage and requires the
nightly toolchain using ip_in_core feature.