netaddr2 0.1.2

A Rust network address parsing and arithmetic library
Documentation

rust-netaddr (netaddr2) • Build Status codecov

This crate is meant as a replacement for an existing reimplementation of various "netaddr" libraries that other languages have. There does exist another netaddr crate, however the author of this crate did not respond when asked about maintainership status.

This crate aims to be as simple and straightforward as possible. We accomplish the desired results by only introducing one new data structure on top of the existing std::net::IpAddr frameworks, which were added to the Rust language in version 1.7.0. We have no dependencies (except std) by default and will only accept additional dependencies on an opt-in basis. Support for no_std will come at a later date if std::net::IpAddr can be ported. (PRs are definitely welcome.)

Usage

There are a few ways to use this library. Perhaps most ergonomical of these is to use the FromStr trait:

let net: NetAddr = "ff02::1/128".parse().expect("couldn't parse an IPv6 address");

(More options will be added eventually.)

Maintenance Status

This codebase is still not feature-complete. Check out the issue tracker if you want to contribute, and don't hesistate to ask for something in an Issue. That said, the business logic is tested and should work. We will release version 1.0 when the GitHub milestone has been fully resolved.

Testing

This project is tested both on concrete RFC5737/RFC3849 IPv4 and IPv6 documentation prefixes of:

  • 192.0.2.0/24 (TEST-NET-1)
  • 198.51.100.0/24 (TEST-NET-2)
  • 203.0.113.0/24 (TEST-NET-3)
  • 2001:DB8::/32

as well as randomly-generated IP addresses in the test suite to demonstrate full correctness.

License

Copyright © 2019 Kristofer J. Rye

This software is released under either of:

at your discretion. Please see the license file (LICENSE.md) for more information.

Acknowledgements

We would like to thank the developers of the netaddr Ruby gem for inspiring the development and ergonomics of this project.