diff --git a/README.md b/README.md index b07c4af..69da1a5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +ipnetwork +=== This is a library to work with IPv4 and v6 CIDRs in rust The IPv4 implementation is stable, IPv6 implementation is not done yet. @@ -9,8 +11,7 @@ Run Clippy by doing cargo test --features "dev" ``` -Installation -============= +### Installation This crate works with Cargo. Assuming you have Rust and Cargo installed, simply check out the source and run tests: ``` git clone https://github.com/achanda/ipnetwork diff --git a/src/common.rs b/src/common.rs index 9842e9a..0465774 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,6 @@ use std::net::Ipv4Addr; +/// Represents a bunch of errors that can occur while working with a `IpNetwork` #[derive(Debug,Clone,PartialEq,Eq)] pub enum IpNetworkError { InvalidAddr(String), diff --git a/src/ipv4.rs b/src/ipv4.rs index 59f1379..3f31991 100644 --- a/src/ipv4.rs +++ b/src/ipv4.rs @@ -6,6 +6,7 @@ use common::{IpNetworkError, cidr_parts, parse_prefix, parse_addr}; const IPV4_BITS: u8 = 32; +/// Represents a network range where the IP addresses are of v4 #[derive(Debug,Clone,Copy,Hash,PartialEq,Eq)] pub struct Ipv4Network { addr: Ipv4Addr, diff --git a/src/ipv6.rs b/src/ipv6.rs index 3ccad72..bdb0247 100644 --- a/src/ipv6.rs +++ b/src/ipv6.rs @@ -8,6 +8,7 @@ use common::{IpNetworkError, cidr_parts, parse_prefix}; const IPV6_BITS: u8 = 128; const IPV6_SEGMENT_BITS: u8 = 16; +/// Represents a network range where the IP addresses are of v6 #[derive(Debug,Clone,Copy,Hash,PartialEq,Eq)] pub struct Ipv6Network { addr: Ipv6Addr, diff --git a/src/lib.rs b/src/lib.rs index cc4955b..0a2b155 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +//! The `ipnetwork` crate provides a set of APIs to work with IP CIDRs in +//! Rust. Implementation for IPv4 is more or less stable, IPv6 implementation +//! is still WIP. #![cfg_attr(feature = "dev", feature(plugin))] #![cfg_attr(feature = "dev", plugin(clippy))] #![crate_type = "lib"] @@ -12,7 +15,8 @@ pub use ipv4::{Ipv4Network, ipv4_mask_to_prefix}; pub use ipv6::{Ipv6Network, ipv6_mask_to_prefix}; pub use common::IpNetworkError; -// A network +/// Represents a generic network range. This type can have two variants: +/// the v4 and the v6 case. #[derive(Debug,Clone,Copy,Hash,PartialEq,Eq)] pub enum IpNetwork { V4(Ipv4Network),