cidr/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "no_unsafe", forbid(unsafe_code))]
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![doc(html_root_url = "https://docs.rs/cidr/0.2.3")]
#![allow(clippy::match_like_matches_macro)]
//! This library provides types to represent an IP network ([`Cidr`]) or
//! an IP host withing a network ([`Inet`])
//!
//! The naming follows the names of the [PostgreSQL data types](https://www.postgresql.org/docs/current/static/datatype-net-types.html)
//!
//! Address parsing also accepts IPv4 address with less than four octets
//! (but always parses those as decimal); this is deprecated and will be
//! removed in 0.3.0.
//!
//! If the `#` flag is used with the `Display` formatting (i.e. `{:#}`) the
//! prefix will be shown even for host addresses (added in `0.1.1`).
//!
//! # Feature `no_unsafe`
//!
//! Enables `#![forbid(unsafe_code)]` for the whole crate; needs to use
//! some workarounds that are likely slower than their `unsafe` variants.
//!
//! # Feature `std`
//!
//! Enabled by default, also mandatory right now because [`std::net`] isn't
//! available in [`core`].
//!
//! # Feature `serde`
//!
//! This feature enables various types to be serialized using `serde`
//! (without `serde-derive`).
//!
//! In human readable formats the `Display` and `FromStr` interfaces are
//! used. Otherwise all values are serialized in the same format (apart
//! from the newtype wrapping) as a tuple of two values:
//!
//! - `tag: u8`:
//! - `0x00...0x20`: IPv4 with network length `tag`
//! - `0x40...0xc0`: IPv6 with network length `tag - 0x40`
//! - `0xff`: `any`
//! - address according to `tag`: [`Ipv4Addr`] (`[u8; 4]`), [`Ipv6Addr`]
//! (`[u8; 16]`) or `()`
//!
//! The represenation hasn't been changed in 0.2; it is compatible with 0.1.
//!
//! # Feature `bitstring`
//!
//! This feature allows various types to be used as [`bitstring::BitString`],
//! which allows them being in used in containers like [bitstring-trees].
//!
//! [bitstring-trees]: https://crates.io/crates/bitstring-trees
//!
//! [`Ipv4Addr`]: std::net::Ipv4Addr
//! [`Ipv6Addr`]: std::net::Ipv6Addr
pub use self::{
cidr::{
AnyIpCidr,
IpCidr,
Ipv4Cidr,
Ipv6Cidr,
},
family::Family,
inet::{
IpInet,
Ipv4Inet,
Ipv6Inet,
},
inet_iterator::{
InetAddressIterator,
InetIterator,
},
inet_pair::{
IpInetPair,
Ipv4InetPair,
Ipv6InetPair,
},
traits::{
Address,
Cidr,
Inet,
InetPair,
},
};
pub mod errors;
pub mod parsers;
mod serde_common;
mod address;
mod cidr;
mod family;
mod inet;
mod inet_iterator;
mod inet_pair;
mod internal_traits;
mod local_addr_parser;
mod num;
mod traits;