fancy-ip

Crates.iofancy-ip
lib.rsfancy-ip
version1.1.0
sourcesrc
created_at2023-05-23 12:41:59.041574
updated_at2023-05-25 05:23:26.365137
descriptionFanciest way to initialize IP addresses
homepage
repositoryhttps://github.com/citorva/fancy-ip
max_upload_size
id871986
size23,284
(citorva)

documentation

README

Elegantly initialize IP and socket addresses.

Crates.io Documentation MIT licensed Build Status

Overview

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.

Usage

In std contexts

This 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.

In no-std contexts

This 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.

Commit count: 16

cargo fmt