Code Monkey home page Code Monkey logo

rust-netaddr2's Introduction

rust-netaddr2 (netaddr2) • Build Status codecov version downloads docs.rs

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.

What it does

NetAddr arose out of a need to mask and subnet IP space in a manner identical to that which routers and network interfaces do. Its utility may be most fully realized in the development of tooling for such purposes.

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().unwrap();
let net: Netv4Addr = "203.0.113.19/29".parse().unwrap();

You can do some operations with these parsed structures, like checking address containment:

let net: NetAddr = "10.10.10.0/24".parse().unwrap();
let addr: IpAddr = "10.10.10.1".parse().unwrap();
assert!(net.contains(&addr));

(More options will be added eventually.)

Vision

This crate aims to be as simple and straightforward as possible. We accomplish this by mirroring the structure of the std::net::Ip.*Addr data structures. Most of the operations on NetAddr structs are implemented through the use of traits which are implemented both on the main structures and on the enum that bridges them. These are also implemented, where appropriate, for standard library structures.

This crate has no dependencies, and will not accept any unless required for no_std support. The only part of this crate that uses std is the part that bridges with std::net::IpAddr, so a potential contribution would be to generalize std::net::IpAddr in a no_std environment.

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.

License

Copyright © 2019—2022 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.