rust-netaddr (netaddr2
) •
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;
(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:
- The Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0) or
- The MIT License, (http://opensource.org/licenses/MIT)
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.