commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
bcb23be0fc2ac125c30608711dad39651e145713 | rushmorem | 2021-03-22T08:04:04 | (cargo-release) version 2.0.6 | diff --git a/Cargo.toml b/Cargo.toml
index ef2158a..35e8aff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.6-alpha.0"
+version = "2.0.6"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
3ba81b165d3eaab82aa378d2d68aaaf0260fb915 | rushmorem | 2021-03-22T08:03:43 | inline hash and cmp methods | diff --git a/src/lib.rs b/src/lib.rs
index 930a139..4352ca2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -155,18 +155,21 @@ impl PartialEq<&str> for Suffix<'_> {
}
impl Ord for Suffix<'_> {
+ #[inline]
fn cmp(&self, other: &Self) -> Ordering {
self.trim().bytes.cmp(strip_dot(other.bytes))
}
}
... | 1 | 6 | 0 |
64d5bea410d8ef66b9284e5f9c212893052caff8 | rushmorem | 2021-03-21T20:15:20 | (cargo-release) start next development iteration 2.0.6-alpha.0 | diff --git a/Cargo.toml b/Cargo.toml
index 4b0fc6a..ef2158a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.5"
+version = "2.0.6-alpha.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
2ddedaa23da0058853597fb1cabeaa0a0133662c | rushmorem | 2021-03-21T20:15:04 | (cargo-release) version 2.0.5 | diff --git a/Cargo.toml b/Cargo.toml
index a08ab41..4b0fc6a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.5-alpha.0"
+version = "2.0.5"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
cd2c5f7f5838f6995c26b48b61b3f344277dbd9e | rushmorem | 2021-03-21T17:24:30 | (cargo-release) start next development iteration 2.0.5-alpha.0 | diff --git a/Cargo.toml b/Cargo.toml
index 59cc5e2..a08ab41 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.4"
+version = "2.0.5-alpha.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
220d776c944357b140065bdb4086df6e6134c720 | rushmorem | 2021-03-21T17:24:14 | (cargo-release) version 2.0.4 | diff --git a/Cargo.toml b/Cargo.toml
index 1d1b124..59cc5e2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.4-alpha.0"
+version = "2.0.4"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
dd91002860229167c2b63c0189c2a3898049808b | rushmorem | 2021-03-21T16:29:26 | make comparisons fqdn insensitive | diff --git a/src/lib.rs b/src/lib.rs
index b638f0c..0595815 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,6 +3,8 @@
#![no_std]
#![forbid(unsafe_code)]
+use core::cmp::Ordering;
+
/// A list of all public suffixes
pub trait List {
/// Finds the suffix information of the given input labels
@@ -82,7 +84,7 @@ p... | 1 | 86 | 6 |
2577351cc27fca00fca7f1c18d3decbef4c13de4 | rushmorem | 2021-03-21T02:11:17 | (cargo-release) start next development iteration 2.0.4-alpha.0 | diff --git a/Cargo.toml b/Cargo.toml
index 9302114..1d1b124 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.3"
+version = "2.0.4-alpha.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
7db983c39a8867e45e4f6965e64ee5f720810435 | rushmorem | 2021-03-21T02:10:59 | (cargo-release) version 2.0.3 | diff --git a/Cargo.toml b/Cargo.toml
index d0693da..9302114 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.3-alpha.0"
+version = "2.0.3"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
aaba69e0a64801d5ab02055cb8ae8ac1400b4d82 | rushmorem | 2021-03-21T02:05:02 | add tests | diff --git a/src/lib.rs b/src/lib.rs
index 5136dac..b638f0c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -113,12 +113,14 @@ impl Suffix<'_> {
}
impl PartialEq<&[u8]> for Suffix<'_> {
+ #[inline]
fn eq(&self, other: &&[u8]) -> bool {
self.bytes == *other
}
}
impl PartialEq<&str> for Suffix<'... | 1 | 74 | 0 |
8eeb5954c14d9dd137ca29197728366a296bccbc | rushmorem | 2021-03-20T09:31:18 | add note about labels | diff --git a/src/lib.rs b/src/lib.rs
index bf1e4c6..5136dac 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,6 +6,8 @@
/// A list of all public suffixes
pub trait List {
/// Finds the suffix information of the given input labels
+ ///
+ /// *NB:* `labels` must be in reverse order
fn find<'a, T>(&self, l... | 1 | 2 | 0 |
96d2509732707f082a753a2b6b6895161a613c18 | rushmorem | 2021-03-15T09:33:13 | (cargo-release) start next development iteration 2.0.3-alpha.0 | diff --git a/Cargo.toml b/Cargo.toml
index 2275552..d0693da 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.2"
+version = "2.0.3-alpha.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
8063d4e61b7d99a592f730650b6ae8c859afb33e | rushmorem | 2021-03-15T09:32:55 | (cargo-release) version 2.0.2 | diff --git a/Cargo.toml b/Cargo.toml
index 430ad24..2275552 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.2-alpha.0"
+version = "2.0.2"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
2faa7715cb53c0530ffedcd6648b433f37d1fd10 | rushmorem | 2021-03-15T09:32:23 | remove lifetime on trait name | diff --git a/src/lib.rs b/src/lib.rs
index f9d8242..bf1e4c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,9 +4,9 @@
#![forbid(unsafe_code)]
/// A list of all public suffixes
-pub trait List<'a> {
+pub trait List {
/// Finds the suffix information of the given input labels
- fn find<T>(&self, labels: T) -> ... | 1 | 14 | 4 |
62512151312662d01c21aecab48ab5beb676d402 | rushmorem | 2021-03-14T19:27:59 | (cargo-release) start next development iteration 2.0.2-alpha.0 | diff --git a/Cargo.toml b/Cargo.toml
index d9d3e73..430ad24 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.1"
+version = "2.0.2-alpha.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
6777a2b00303279b633bdd0bbdfc3efe3be95d7d | rushmorem | 2021-03-14T19:27:42 | (cargo-release) version 2.0.1 | diff --git a/Cargo.toml b/Cargo.toml
index c444668..d9d3e73 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.1-alpha.0"
+version = "2.0.1"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
199318a6056ccc4cd5e24e5e0e91bb4292b29f00 | rushmorem | 2021-03-14T19:26:10 | support Rust v1.41 for Isahc | diff --git a/src/lib.rs b/src/lib.rs
index f8ea2c0..f9d8242 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -93,8 +93,9 @@ impl Suffix<'_> {
self.typ
}
+ // Could be const but Isahc needs support for Rust v1.41
#[inline]
- pub const fn is_known(&self) -> bool {
+ pub fn is_known(&self) -> bool... | 1 | 2 | 1 |
f1cab212024f7538da0b47eb834221df40765a37 | rushmorem | 2021-03-12T20:42:51 | (cargo-release) start next development iteration 2.0.1-alpha.0 | diff --git a/Cargo.toml b/Cargo.toml
index 5df0aa4..c444668 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.0"
+version = "2.0.1-alpha.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
57b0079474749b95a635ba01bc42f93b5b3f690a | rushmorem | 2021-03-12T20:42:32 | (cargo-release) version 2.0.0 | diff --git a/Cargo.toml b/Cargo.toml
index 2f2f124..5df0aa4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "psl-types"
description = "Common types for the public suffix implementation crates"
-version = "2.0.0-alpha.0"
+version = "2.0.0"
license = "MIT/Apache-2.0"
repository = "https://g... | 1 | 1 | 1 |
6e87cbee629c3e22f3dbee56cc2acb0834344e69 | rushmorem | 2021-03-12T19:48:39 | update description | diff --git a/Cargo.toml b/Cargo.toml
index d51286b..2f2f124 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "psl-types"
-description = "A native library for Mozilla's Public Suffix List"
+description = "Common types for the public suffix implementation crates"
version = "2.0.0-alpha.0"
lic... | 1 | 1 | 1 |
f01575cbf2fc596c0a1761c122aa92525cbb7974 | Nikolai Golub | 2025-07-11T15:43:06 | Upgrade schemars to 1.0 (#226)
* Compilation passes
* Simplified JSON validation without does_it_json
* Extend tests a little bit | diff --git a/Cargo.toml b/Cargo.toml
index fc6a421..cbe0fa7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,12 +13,11 @@ rust-version = "1.80.0"
[dependencies]
serde = { version = "1.0.200", optional = true }
-schemars = { version = "0.8.17", optional = true }
+schemars = { version = "1.0.4", optional = true }
[... | 5 | 141 | 128 |
c3af07d69a1a073f290e392baafa63ad480e6550 | Imbolc | 2025-03-22T20:30:10 | Impl From<Ipv4Addr, Ipv6Addr> for IpNetwork (#218) | diff --git a/src/lib.rs b/src/lib.rs
index 24ec499..1b64562 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -8,7 +8,12 @@
unused_import_braces
)]
-use std::{convert::TryFrom, fmt, net::IpAddr, str::FromStr};
+use std::{
+ convert::TryFrom,
+ fmt,
+ net::{IpAddr, Ipv4Addr, Ipv6Addr},
+ str::FromStr,
+};
... | 1 | 20 | 3 |
35977adc8103cfc232bc95fbc32f4e34f2b6a6d7 | Kieran | 2025-02-28T16:00:56 | Iterator size hints (#217)
* feat: iterator size hints
* fix: add size_hint to IpNetworkIterator | diff --git a/src/ipv4.rs b/src/ipv4.rs
index c977f69..086cfc4 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -368,6 +368,15 @@ impl Iterator for Ipv4NetworkIterator {
};
Some(next.into())
}
+
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ if let Some(n) = self.next {
+ le... | 3 | 55 | 0 |
0deb2abd8b28ea746e9922207f4d8c6703899783 | Markus Pettersson | 2025-01-13T04:04:28 | Add `ip_mask_to_prefix_checked` (#214)
* Add `ipv4_mask_to_prefix_checked`
* Add `ipv6_mask_to_prefix_checked`
* Add `ip_mask_to_prefix_checked` | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 945813d..c977f69 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -382,13 +382,24 @@ impl IntoIterator for &'_ Ipv4Network {
///
/// If the mask is invalid this will return an `IpNetworkError::InvalidPrefix`.
pub fn ipv4_mask_to_prefix(mask: Ipv4Addr) -> Result<u8, IpNetwork... | 3 | 50 | 13 |
170fc4ca6b6293520aadfa22fe3601c20d4505f0 | Markus Pettersson | 2025-01-13T04:03:05 | Add `rust-version` to `Cargo.toml` and set MSRV to 1.80.0 (#215) | diff --git a/Cargo.toml b/Cargo.toml
index e42db50..fc6a421 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ keywords = ["network", "ip", "address", "cidr"]
readme = "README.md"
categories = ["network-programming", "parser-implementations"]
edition = "2021"
+rust-version = "1.80.0"
[dependencies]
serde =... | 1 | 1 | 0 |
aa65f088b175edf875550bad13efbe074193b19e | Markus Pettersson | 2025-01-09T19:06:22 | Make `IpNetwork::is_ipv4` and `IpNetwork::is_ipv6` const (#213) | diff --git a/src/lib.rs b/src/lib.rs
index 79e9026..86abf42 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -245,7 +245,7 @@ impl IpNetwork {
/// assert_eq!(v4.is_ipv4(), true);
/// assert_eq!(v4.is_ipv6(), false);
///```
- pub fn is_ipv4(&self) -> bool {
+ pub const fn is_ipv4(&self) -> bool {
... | 1 | 2 | 2 |
5f929258ef9530a129713f730ca54225f87be1f2 | Markus Pettersson | 2025-01-08T23:38:34 | Make `IpNetwork::ip` const (#212) | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 3842779..945813d 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -140,7 +140,7 @@ impl Ipv4Network {
}
}
- pub fn ip(self) -> Ipv4Addr {
+ pub const fn ip(self) -> Ipv4Addr {
self.addr
}
diff --git a/src/ipv6.rs b/src/ipv6.rs
index 501a5e7... | 3 | 3 | 3 |
a21f5df04e7a62719949d828f1a7ddb370bd6ad7 | Markus Pettersson | 2025-01-08T23:38:16 | Make `IpNetwork::broadcast` const (#211) | diff --git a/src/ipv4.rs b/src/ipv4.rs
index c5646e3..3842779 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -219,10 +219,10 @@ impl Ipv4Network {
/// let net: Ipv4Network = "10.9.0.32/16".parse().unwrap();
/// assert_eq!(net.broadcast(), Ipv4Addr::new(10, 9, 255, 255));
/// ```
- pub fn broadcast(&sel... | 3 | 9 | 9 |
876f882523fc12baee39e5e1960745860d4132fc | Markus Pettersson | 2025-01-08T23:37:32 | Make `IpNetwork::network` const (#210) | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 15b46d9..c5646e3 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -201,10 +201,10 @@ impl Ipv4Network {
/// let net: Ipv4Network = "10.1.9.32/16".parse().unwrap();
/// assert_eq!(net.network(), Ipv4Addr::new(10, 1, 0, 0));
/// ```
- pub fn network(&self) -> Ip... | 2 | 5 | 5 |
49f07a4838c92f14fbb69d7a3ade88f20b08d562 | Markus Pettersson | 2025-01-08T23:36:53 | Make `IpNetwork::prefix` const (#209) | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 5906ef0..15b46d9 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -144,7 +144,7 @@ impl Ipv4Network {
self.addr
}
- pub fn prefix(self) -> u8 {
+ pub const fn prefix(self) -> u8 {
self.prefix
}
diff --git a/src/ipv6.rs b/src/ipv6.rs
index 2... | 3 | 3 | 3 |
2f219a2ada47fc9a8396360dfc6c8211dbbf3b42 | Markus Pettersson | 2025-01-08T16:22:33 | Make `IpNetwork::contains` const (#208)
* Make `Ipv6Network::contains` const
* Make `Ipv4Network::contains` const
* Make `IpNetwork::contains` const | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 0ca3468..5906ef0 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -238,12 +238,12 @@ impl Ipv4Network {
/// assert!(!net.contains(Ipv4Addr::new(127, 0, 1, 70)));
/// ```
#[inline]
- pub fn contains(&self, ip: Ipv4Addr) -> bool {
+ pub const fn contains(&sel... | 3 | 12 | 12 |
9ae719637d719b937157a3e5e4aec01d905f54fc | Markus Pettersson | 2025-01-08T03:03:10 | Make `IpNetwork::mask` const (#207)
* Make `Ipv4Network::mask` const
* Make `Ipv6Network::mask` const
* Make `IpNetwork::mask` const | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 58d834c..0ca3468 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -180,13 +180,13 @@ impl Ipv4Network {
/// let net: Ipv4Network = "127.0.0.0/16".parse().unwrap();
/// assert_eq!(net.mask(), Ipv4Addr::new(255, 255, 0, 0));
/// ```
- pub fn mask(&self) -> Ipv4A... | 3 | 5 | 5 |
e1d3ac6de15aa65f41751ddadeb2b760a43938db | Beau Gieskens | 2025-01-07T04:13:12 | Fix for 0::/0 network (#205) | diff --git a/src/ipv6.rs b/src/ipv6.rs
index fb12f1a..7e6206c 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -203,6 +203,9 @@ impl Ipv6Network {
pub fn mask(&self) -> Ipv6Addr {
debug_assert!(self.prefix <= IPV6_BITS);
+ if self.prefix == 0 {
+ return Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, ... | 1 | 20 | 0 |
4f7d898a86c076852c78347dda395271d8a9bd9b | Markus Pettersson | 2025-01-06T03:19:04 | Replace `Ipv{4,6}Network::new_unchecked` with `Ipv{4,6}Network::new_checked` (#203)
* Replace `Ipv4Network::new_unchecked` with `Ipv4Network::new_checked`
* Replace `Ipv6Network::new_unchecked` with `Ipv6Network::new_checked`
* Update doc test for `Ipv{4,6}Network::new_checked` to use `should_panic`
* Better demons... | diff --git a/src/ipv4.rs b/src/ipv4.rs
index e7acdee..58d834c 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -67,19 +67,17 @@ impl Ipv4Network {
///
/// If the prefix is larger than 32 this will return an `IpNetworkError::InvalidPrefix`.
pub const fn new(addr: Ipv4Addr, prefix: u8) -> Result<Ipv4Network, ... | 3 | 79 | 39 |
d665bb6beb5936f156ad863207f6584934d6ef62 | Linus Färnstrand | 2024-09-24T15:40:42 | Make the serde feature opt-in instead of opt-out (#200)
Most people add dependencies without checking their features
or optional dependencies too carefully. This leads to them pulling in
transitive dependencies they likely don't need. | diff --git a/Cargo.toml b/Cargo.toml
index b37d058..1a9a828 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,10 @@ travis-ci = { repository = "achanda/ipnetwork" }
maintenance = { status = "passively-maintained" }
[features]
-default = ["serde"]
+# Keep optional dependencies out of the default features.
+# Sin... | 1 | 4 | 1 |
ad46759a55eb2e1e3bb8b152848e7792884c9091 | SildCave | 2024-09-07T19:22:12 | fix for 0.0.0.0/0 network (#199) | diff --git a/src/ipv4.rs b/src/ipv4.rs
index f8a0311..e7acdee 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -166,7 +166,9 @@ impl Ipv4Network {
/// ```
pub fn mask(&self) -> Ipv4Addr {
debug_assert!(self.prefix <= 32);
-
+ if self.prefix == 0 {
+ return Ipv4Addr::new(0, 0, 0, 0);
+ ... | 2 | 14 | 1 |
cbf8d6b29ac289a83f2e80f9001e1b59191b89d6 | dsx | 2024-08-10T01:53:42 | Fix typo (#198) | diff --git a/src/ipv6.rs b/src/ipv6.rs
index 64d90c8..ea35cc3 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -90,7 +90,7 @@ impl Ipv6Network {
///
/// # Safety
///
- /// The caller must ensure that the prefix is less than or equal to 32.
+ /// The caller must ensure that the prefix is less than or e... | 1 | 1 | 1 |
f0fd0521e14976bfad8551a9d32a496b589693b9 | Abhishek Chanda | 2024-05-01T02:49:56 | fix: use associated constants (#191) | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 4ad0b8c..f8a0311 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -540,7 +540,7 @@ mod test {
fn iterator_v4_huge() {
let cidr: Ipv4Network = "0/0".parse().unwrap();
let mut iter = cidr.iter();
- for i in 0..(u32::max_value() as u64 + 1) {
+ ... | 2 | 2 | 2 |
70d1f74e292203577dfb5418a823c4fc8104e51d | Christopher Mahoney | 2024-05-01T02:41:17 | ipv6: rewrite core ipv6 methods to operate on u128s (#187)
* errors: adds `From<AddrParseError>` for `IpNetworkError`
* ipv4: adds safety comment to `new_unchecked` and debug assertions to verify compliance
* ipv6: rewrite core ipv6 methods to operate on `u128`s | diff --git a/src/error.rs b/src/error.rs
index e58781b..4c8120b 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,4 +1,4 @@
-use std::{error::Error, fmt};
+use std::{error::Error, fmt, net::AddrParseError};
use crate::error::IpNetworkError::*;
@@ -9,7 +9,7 @@ pub enum IpNetworkError {
InvalidAddr(String),
... | 3 | 117 | 81 |
241b1dcdf84c7e02ecc542c2ad2bc2d5610fe692 | Christopher Mahoney | 2024-04-30T03:23:28 | netsize: Hash implementation to match PartialEq (#186)
* netsize: hash implementation to match PartialEq
* netsize: Prefer `From` over `Into`, add documentation, and add Hash and PartialEq tests | diff --git a/src/size.rs b/src/size.rs
index c03f788..be0c8ec 100644
--- a/src/size.rs
+++ b/src/size.rs
@@ -1,20 +1,41 @@
-use std::{cmp::Ordering, fmt::Display};
+use std::{
+ cmp::Ordering,
+ fmt::Display,
+ hash::{Hash, Hasher},
+};
use crate::error::NetworkSizeError;
+use NetworkSize::*;
-/// Represe... | 1 | 78 | 32 |
a1966d40898faba1136a2e75d85a8602a5a7e7f3 | Aurélie Alvet | 2023-12-21T15:03:04 | Add const unsafe `new_unchecked` to `Ipv4Network` & `Ipv6Network` (#185)
* Add const unsafe `new_unchecked` to `Ipv4Network` & `Ipv6Network`
* New tests added for `new_unchecked` functions | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 7627894..3722fd0 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -74,6 +74,12 @@ impl Ipv4Network {
}
}
+ /// Constructs without checking prefix a new `Ipv4Network` from any `Ipv4Addr,
+ /// and a prefix denoting the network size.
+ pub const unsafe fn... | 3 | 29 | 1 |
1bd937e90c4395fdecfded61cc84b2f594526e09 | Fredrick Brennan | 2023-06-14T02:17:39 | Add `Ipv6Network::nth` to get the nth address (take two) (#176)
* Add `Ipv6Network::nth` to get the nth address
Works the same as `Ipv4Network::nth`, but using a `u128` index instead
of `u32`.
* add IpNetwork v6 nth test
---------
Co-authored-by: Josh Triplett <josh@joshtriplett.org> | diff --git a/src/ipv6.rs b/src/ipv6.rs
index 599ec97..645f9a1 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -247,6 +247,30 @@ impl Ipv6Network {
let host_bits = u32::from(IPV6_BITS - self.prefix);
2u128.pow(host_bits)
}
+
+ /// Returns the `n`:th address within this network.
+ /// The adres... | 1 | 46 | 0 |
d19ac33071d360db9afa4187c0d7b51bca10dfd5 | Fredrick Brennan | 2023-06-14T02:14:02 | Added needed traits to `NetworkSize` (#175)
* Add conversion and better equality traits to NetworkSize
* Add tests for NetworkSize conversion/equality
* impl Display for NetworkSize | diff --git a/src/error.rs b/src/error.rs
new file mode 100644
index 0000000..e58781b
--- /dev/null
+++ b/src/error.rs
@@ -0,0 +1,50 @@
+use std::{error::Error, fmt};
+
+use crate::error::IpNetworkError::*;
+
+/// Represents a bunch of errors that can occur while working with a `IpNetwork`
+#[derive(Debug, Clone, Partia... | 6 | 221 | 42 |
0bb1ea8fd472c617e1cf37f73e45811ebbd3b672 | Abhishek Chanda | 2023-04-07T17:05:59 | Replace assert_eq with assert for bool comparison | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 8cc0399..add244d 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -669,9 +669,9 @@ mod test {
let other3: Ipv4Network = "1.2.2.64/26".parse().unwrap();
let skynet: Ipv4Network = "1.2.3.0/24".parse().unwrap();
- assert_eq!(skynet.overlaps(other), true)... | 1 | 3 | 3 |
b624487f72c80bf5291dca9b871350a653d3d1ed | Abhishek Chanda | 2023-04-07T17:04:10 | Use cargo clippy --fix to autofix code | diff --git a/src/common.rs b/src/common.rs
index ee92984..4b65554 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -12,9 +12,9 @@ impl fmt::Display for IpNetworkError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use crate::IpNetworkError::*;
match *self {
- InvalidAddr... | 3 | 9 | 18 |
dff59ea0a5c62c043d9bb016a0000731f9c35959 | Abhishek Chanda | 2023-04-07T02:14:15 | Add a reference where missing | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 9a39aea..aaac71f 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -156,7 +156,7 @@ impl Ipv4Network {
/// let net: Ipv4Network = "10.1.9.32/16".parse().unwrap();
/// assert_eq!(net.network(), Ipv4Addr::new(10, 1, 0, 0));
/// ```
- pub fn network(self) -> Ipv4A... | 1 | 3 | 3 |
432f7342e3a5ebcd70e71954de089982f79b6b24 | Abhishek Chanda | 2023-04-07T02:10:36 | Cleanup mask for Ipv4Addr | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 00e7b14..9a39aea 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -139,11 +139,10 @@ impl Ipv4Network {
/// let net: Ipv4Network = "127.0.0.0/16".parse().unwrap();
/// assert_eq!(net.mask(), Ipv4Addr::new(255, 255, 0, 0));
/// ```
- pub fn mask(self) -> Ipv4Ad... | 1 | 3 | 4 |
b15eb54695c011a84e38ed7e685df49eb1da2fc2 | Abhishek Chanda | 2023-04-07T02:07:54 | Shrink the enumerate call on mask | diff --git a/src/ipv6.rs b/src/ipv6.rs
index 865d0ac..2a3822f 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -192,15 +192,17 @@ impl Ipv6Network {
/// assert_eq!(net.mask(), Ipv6Addr::new(0xffff, 0xffff, 0, 0, 0, 0, 0, 0));
/// ```
pub fn mask(&self) -> Ipv6Addr {
- // Ipv6Addr::from is only implem... | 1 | 7 | 5 |
ec79428c7573917ee231fda9a63b864476780d56 | Abhishek Chanda | 2023-04-07T02:03:29 | Cleanup both size functions | diff --git a/src/ipv4.rs b/src/ipv4.rs
index d162fb6..00e7b14 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -215,9 +215,8 @@ impl Ipv4Network {
/// assert_eq!(tinynet.size(), 1);
/// ```
pub fn size(self) -> u32 {
- let host_bits = u32::from(IPV4_BITS - self.prefix);
- (2 as u32).pow(host_b... | 2 | 3 | 4 |
a96f30d64e924975ba92254b41d8d8e364c65733 | Abhishek Chanda | 2023-04-07T01:56:31 | Simplify FromStr for Ipv6Network | diff --git a/src/ipv6.rs b/src/ipv6.rs
index b2299df..756c3a9 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -263,16 +263,14 @@ impl FromStr for Ipv6Network {
type Err = IpNetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let (addr_str, prefix_str) = cidr_parts(s)?;
- let addr = I... | 1 | 5 | 7 |
ef3f536d485cedbf4b1b23476481f8207c926918 | Abhishek Chanda | 2023-04-07T01:47:22 | Make parse_prefix more idiomatic | diff --git a/src/common.rs b/src/common.rs
index 1e05ed6..ee92984 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -51,12 +51,14 @@ pub fn cidr_parts(cidr: &str) -> Result<(&str, Option<&str>), IpNetworkError> {
}
pub fn parse_prefix(prefix: &str, max: u8) -> Result<u8, IpNetworkError> {
- let mask = prefix
- ... | 1 | 10 | 8 |
1b6904bfc7c8831b928f48e4f0c110fd34104c28 | Abhishek Chanda | 2022-07-01T03:00:50 | Cut a new release for v0.20.0 (#158) | diff --git a/Cargo.toml b/Cargo.toml
index fe702f5..eeac300 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.19.0"
+version = "0.20.0"
authors = ["Abhishek Chanda <abhishek.becs@gmail.com>", "Linus Färnstrand <faern@faern.net>"]
description = "A library to work wit... | 1 | 1 | 1 |
86dbbd997a728dd7b9a456e6821ded58b7b7f097 | Aleksandr Pak | 2022-05-31T20:37:44 | [#153] Add optional JSONSchema implementation for IpNetwork
Problem: No instance of `JSONSchema` is implemented for
`IpNetwork`.
Solution: Derive implementation via `schemars`. Add corresponding
feature to the crate. | diff --git a/Cargo.toml b/Cargo.toml
index d498210..5f7e589 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,7 @@ edition = "2021"
[dependencies]
serde = { version = "1", optional = true }
+schemars = { version = "0.8.10", optional = true }
[dev-dependencies]
serde_json = "1.0"
diff --git a/src/ipv4.rs b/s... | 4 | 4 | 0 |
3503e4c094bbc756db4f50542bfe1807129da9f5 | Abhishek Chanda | 2022-04-13T03:44:10 | Cut a new release for v0.19.0
This one is still a manual release, I am hoping to get this automated
soon. | diff --git a/Cargo.toml b/Cargo.toml
index df2c468..d498210 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.18.0"
+version = "0.19.0"
authors = ["Abhishek Chanda <abhishek.becs@gmail.com>", "Linus Färnstrand <faern@faern.net>"]
description = "A library to work wit... | 1 | 1 | 1 |
501e5533d7f7b45dbc08e45ab3a26fa69768a868 | Abhishek Chanda | 2022-04-13T03:35:37 | Remove the redundant html_root_url attribute | diff --git a/Cargo.toml b/Cargo.toml
index d99a3f1..df2c468 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.18.0" # When updating version, also modify html_root_url in the lib.rs
+version = "0.18.0"
authors = ["Abhishek Chanda <abhishek.becs@gmail.com>", "Linus Fär... | 2 | 1 | 2 |
a57afd9e1ad8aa03b26035fbb4340ff974b80dce | Paolo Barbolini | 2021-12-29T15:07:07 | Remove useless allocation when serializing | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 9cb84a4..9fde814 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -27,7 +27,7 @@ impl serde::Serialize for Ipv4Network {
where
S: serde::Serializer,
{
- serializer.serialize_str(&self.to_string())
+ serializer.collect_str(self)
}
}
diff ... | 3 | 3 | 3 |
9651b3b72196376e4df0c435ce62a4b559578df7 | Abhishek Chanda | 2021-11-08T15:04:50 | feat: Upgrade rust edition
cargo fix --edition did not result in any changes to src | diff --git a/Cargo.toml b/Cargo.toml
index 4ce2ad2..d99a3f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,7 +8,7 @@ repository = "https://github.com/achanda/ipnetwork"
keywords = ["network", "ip", "address", "cidr"]
readme = "README.md"
categories = ["network-programming", "parser-implementations"]
-edition = "2018... | 1 | 1 | 1 |
c9b2bc5519636f9232126d2f551e94fd70bda399 | Abhishek Chanda | 2021-04-13T23:29:34 | Cut a new release for v0.18.0 | diff --git a/Cargo.toml b/Cargo.toml
index 39f4be3..4ce2ad2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.17.0" # When updating version, also modify html_root_url in the lib.rs
+version = "0.18.0" # When updating version, also modify html_root_url in the lib.rs
a... | 2 | 2 | 2 |
9921661ebe89e07164299fb4a1fb30723a9c70cc | Abhishek Chanda | 2021-04-05T04:05:57 | Always inline the contains function
This function is commonly called in a loop (or iterator). Inlining it
makes it run faster, which is beneficial in this case. | diff --git a/Cargo.toml b/Cargo.toml
index 2705026..39f4be3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,7 +16,7 @@ serde = { version = "1", optional = true }
[dev-dependencies]
serde_json = "1.0"
serde_derive = "1"
-criterion = "0.3.0"
+criterion = {version = "0.3.4", features= ["html_reports"]}
[badges]
tra... | 4 | 4 | 1 |
1f3e10f73d3cfdf16fd016801e2b9da24cc4af4a | Abhishek Chanda | 2021-02-15T17:12:15 | Reexport underlying iterators and do not implement Copy
Closes #138 | diff --git a/src/ipv4.rs b/src/ipv4.rs
index a944598..82472b7 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -271,7 +271,7 @@ impl From<Ipv4Addr> for Ipv4Network {
}
}
-#[derive(Copy, Clone, Debug)]
+#[derive(Clone, Debug)]
pub struct Ipv4NetworkIterator {
next: Option<u32>,
end: u32,
diff --git a/src... | 3 | 5 | 5 |
8fcff82c7b29bd469baef090d6ea99199e91e5fb | Abhishek Chanda | 2020-08-27T17:01:07 | Convert Ipv{4,6}Network::new to const functions
IpNetwork::new cannot be const since it is not supported with the ?
operator
Closes #111 | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 9b0395a..a944598 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -35,7 +35,7 @@ impl Ipv4Network {
/// Constructs a new `Ipv4Network` from any `Ipv4Addr` and a prefix denoting the network size.
///
/// If the prefix is larger than 32 this will return an `IpNetwo... | 2 | 2 | 2 |
e15e8cb812c952280d5988833c2bacda33336f28 | Abhishek Chanda | 2020-08-09T21:27:49 | Implement TryFrom<&str> for all basic types
Also improve some docs and FromStr type signature
Closes #135 | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 51fb7e5..9b0395a 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -1,5 +1,5 @@
use crate::common::{cidr_parts, parse_prefix, IpNetworkError};
-use std::{fmt, net::Ipv4Addr, str::FromStr};
+use std::{fmt, net::Ipv4Addr, str::FromStr, convert::TryFrom};
const IPV4_BITS: u8 = ... | 3 | 43 | 6 |
6c6bdb333d6b6bb3935afe1b9dcd076b8d88ca89 | Abhishek Chanda | 2020-07-13T10:45:28 | Cut a new release | diff --git a/Cargo.toml b/Cargo.toml
index 4d219db..2705026 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.16.0" # When updating version, also modify html_root_url in the lib.rs
+version = "0.17.0" # When updating version, also modify html_root_url in the lib.rs
a... | 2 | 2 | 2 |
1d4665dfe64e828ddf612c7a52d278a65bbd392e | jethrogb | 2020-07-13T10:01:48 | Update serde version
This crate doesn't actually work with serde 0.8 or 0.9. | diff --git a/Cargo.toml b/Cargo.toml
index c1f38f5..4d219db 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,11 +11,11 @@ categories = ["network-programming", "parser-implementations"]
edition = "2018"
[dependencies]
-serde = { version = ">=0.8.0, <2.0", optional = true }
+serde = { version = "1", optional = true }
... | 1 | 2 | 2 |
b6397ca2bc3b72f04147bc4fe2d608a53927dc25 | Abhishek Chanda | 2020-01-18T18:42:49 | Isolate the contains call in bench | diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs
index e081d4d..fb44534 100644
--- a/benches/parse_bench.rs
+++ b/benches/parse_bench.rs
@@ -21,18 +21,18 @@ fn parse_ipv4_netmask_benchmark(c: &mut Criterion) {
}
fn contains_ipv4_benchmark(c: &mut Criterion) {
+ let cidr = "74.125.227.0/25".parse::<Ip... | 1 | 2 | 2 |
45fbf458b30864c7a2e4a5f2d5f67e379468bb1f | Abhishek Chanda | 2020-01-18T17:53:15 | Address all changes clippy pointed out | diff --git a/src/common.rs b/src/common.rs
index 466df22..1e05ed6 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -36,17 +36,17 @@ pub fn cidr_parts(cidr: &str) -> Result<(&str, Option<&str>), IpNetworkError> {
let (ip, prefix) = cidr.split_at(sep);
// Error if cidr has multiple slashes
if ... | 3 | 14 | 14 |
121820add8570846a52432d24e4c508050704380 | Abhishek Chanda | 2020-01-18T17:41:43 | Drop clippy from dependencies | diff --git a/Cargo.toml b/Cargo.toml
index 872fc70..69e061b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,6 @@ categories = ["network-programming", "parser-implementations"]
edition = "2018"
[dependencies]
-clippy = {version = "0.0.302", optional = true}
serde = { version = ">=0.8.0, <2.0", optional = true... | 1 | 0 | 1 |
f23ea4d7d65d97d19087059ba523e02287cfaaef | Abhishek Chanda | 2020-01-18T11:03:37 | Add a few deny lints
And conform to the new ones | diff --git a/src/ipv4.rs b/src/ipv4.rs
index d9b1db2..21c04bd 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -263,7 +263,7 @@ impl From<Ipv4Addr> for Ipv4Network {
}
}
-#[derive(Clone, Debug)]
+#[derive(Copy, Clone, Debug)]
pub struct Ipv4NetworkIterator {
next: Option<u32>,
end: u32,
diff --git a/src... | 3 | 9 | 2 |
ca2da8ae30e2c94e590c630890549a52cd0a794c | Abhishek Chanda | 2020-01-08T10:37:12 | Uprev for a new release | diff --git a/Cargo.toml b/Cargo.toml
index aa0f471..af99c8a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.15.1" # When updating version, also modify html_root_url in the lib.rs
+version = "0.16.0" # When updating version, also modify html_root_url in the lib.rs
a... | 2 | 2 | 2 |
4dfdf142d0e4f451da6813deea5ab66f55d5a9e7 | Abhishek Chanda | 2020-01-08T10:29:58 | Cleanup comment on IPv6 implementation | diff --git a/src/lib.rs b/src/lib.rs
index 61fe347..e69187b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,5 @@
//! 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.
+//! Rust.
#![cfg_attr(featur... | 1 | 1 | 2 |
00256cf88526a8f83c0c8605d09a05296a4de3d0 | Abhishek Chanda | 2020-01-05T13:27:46 | Set a maintenance status
Putting this as passively-maintained since this crate is mostly feature
complete. | diff --git a/Cargo.toml b/Cargo.toml
index e88a627..aa0f471 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,7 @@ criterion = "0.3.0"
[badges]
travis-ci = { repository = "achanda/ipnetwork" }
+maintenance = { status = "passively-maintained" }
[features]
default = ["serde"] | 1 | 1 | 0 |
18677e3b69c5d1217d314de69c2e09093d1de277 | Abhishek Chanda | 2020-01-05T11:38:28 | Run cargo fmt | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 1bbb2fe..d9b1db2 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -64,7 +64,10 @@ impl Ipv4Network {
pub fn iter(&self) -> Ipv4NetworkIterator {
let start = u32::from(self.network());
let end = start + (self.size() - 1);
- Ipv4NetworkIterator { nex... | 3 | 22 | 8 |
986ee0ba1cf16f2b6a1905825a30a9fcedd1ad2f | Abhishek Chanda | 2020-01-05T11:36:49 | Check against specific errors in parsing test | diff --git a/src/ipv4.rs b/src/ipv4.rs
index eb81a5d..1bbb2fe 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -484,8 +484,8 @@ mod test {
}
#[test]
- fn parse_netmask_broken() {
- "192.168.1.0/255.0.255.0".parse::<Ipv4Network>().unwrap_err();
+ fn parse_netmask_broken_v4() {
+ assert_eq!("... | 2 | 7 | 2 |
bc1064e5f04006526cbbfc369b57b4a45120180f | Abhishek Chanda | 2020-01-05T11:12:28 | Add a benchmark for parsing IPv4 netmask | diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs
index 5efd8f0..e081d4d 100644
--- a/benches/parse_bench.rs
+++ b/benches/parse_bench.rs
@@ -2,8 +2,8 @@ use criterion::{criterion_group, criterion_main, Criterion};
use ipnetwork::{Ipv4Network, Ipv6Network};
use std::net::{Ipv4Addr, Ipv6Addr};
-fn parse_i... | 1 | 10 | 3 |
87ea7b24faa631877bf89e26121d03d1c7d1ee85 | Michal 'vorner' Vaner | 2019-12-21T15:16:22 | Be able to parse the netmask format
Allow accepting the netmask format, eg 192.168.1.0/255.255.255.0, in
addition to the more modern /24 prefix version.
Adding support for IPv4 only, as IPv6 never actually used that format in
practice.
Closes #107. | diff --git a/src/ipv4.rs b/src/ipv4.rs
index f873d8e..eb81a5d 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -238,7 +238,13 @@ impl FromStr for Ipv4Network {
let addr = Ipv4Addr::from_str(addr_str)
.map_err(|_| IpNetworkError::InvalidAddr(addr_str.to_string()))?;
let prefix = match prefix_... | 1 | 20 | 1 |
fa5deed40ba0d5792e6e69609cd331c433026257 | Linus Färnstrand | 2019-12-10T08:13:44 | Make the serde dependency optional | diff --git a/Cargo.toml b/Cargo.toml
index c540730..e88a627 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ edition = "2018"
[dependencies]
clippy = {version = "0.0.302", optional = true}
-serde = ">=0.8.0, <2.0"
+serde = { version = ">=0.8.0, <2.0", optional = true }
[dev-dependencies]
serde_json = ... | 5 | 26 | 20 |
5b09d82d43eb3ef6e72ea1d22a7a915ece1ea68d | Michal 'vorner' Vaner | 2019-12-07T20:24:19 | Fix bug with overflow in iterator | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 015c1f4..9a8578c 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -62,8 +62,8 @@ impl Ipv4Network {
/// addresses.
pub fn iter(&self) -> Ipv4NetworkIterator {
let start = u32::from(self.network());
- let end = start + self.size();
- Ipv4NetworkI... | 2 | 17 | 17 |
dbf366cfdf07f9615b95d98e9d344079f7f69fe4 | Michal 'vorner' Vaner | 2019-12-07T18:53:56 | Iterators: reproducer for overflow on high end of iteration | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 0d8ee6a..015c1f4 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -614,4 +614,19 @@ mod test {
assert_eq!(skynet.overlaps(other2), false);
assert_eq!(other2.overlaps(other3), true);
}
+
+ #[test]
+ fn edges() {
+ let low: Ipv4Network = "0.0.0... | 2 | 26 | 0 |
6cbb011597cdf61b2e37655817625f88b5fb2c37 | Michal 'vorner' Vaner | 2019-12-07T18:32:51 | Iterators for the IpNetwork
Version-agnostic iterator in addition to the version specific ones. | diff --git a/src/lib.rs b/src/lib.rs
index 24abf7a..09377d4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,6 +16,8 @@ mod ipv6;
pub use crate::common::IpNetworkError;
pub use crate::ipv4::{ipv4_mask_to_prefix, Ipv4Network};
pub use crate::ipv6::{ipv6_mask_to_prefix, Ipv6Network};
+use crate::ipv4::Ipv4NetworkIterat... | 1 | 41 | 0 |
f7d9524f708898b93d700bda3526a99290274f10 | Michal 'vorner' Vaner | 2019-12-05T19:15:21 | Make the iterators slightly better
* Implement some useful traits on them.
* Make reference an into-iterator. | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 95e2a27..0d8ee6a 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -253,6 +253,7 @@ impl From<Ipv4Addr> for Ipv4Network {
}
}
+#[derive(Clone, Debug)]
pub struct Ipv4NetworkIterator {
next: u32,
end: u32,
@@ -272,6 +273,14 @@ impl Iterator for Ipv4NetworkItera... | 2 | 18 | 0 |
a3197a84118c56ef0e5d561a055f20eb8f132288 | Linus Färnstrand | 2019-12-10T08:33:32 | Remove the "heavily WIP" part of description | diff --git a/Cargo.toml b/Cargo.toml
index 95b2735..c540730 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
name = "ipnetwork"
version = "0.15.1" # When updating version, also modify html_root_url in the lib.rs
authors = ["Abhishek Chanda <abhishek.becs@gmail.com>", "Linus Färnstrand <faern@faern.net>"]
-de... | 1 | 1 | 1 |
0479ca45a9c95ff50682b17e4dc2c0eb7f444232 | Linus Färnstrand | 2019-12-10T08:32:53 | Add and remove appropriate keywords and categories | diff --git a/Cargo.toml b/Cargo.toml
index 5257e33..95b2735 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,9 +5,9 @@ authors = ["Abhishek Chanda <abhishek.becs@gmail.com>", "Linus Färnstrand <faer
description = "A library to work with IP CIDRs in Rust, heavily WIP"
license = "Apache-2.0"
repository = "https://github... | 1 | 2 | 2 |
11025d3b1aaf7bf876b792d9b2a87ecd3915f3a8 | Linus Färnstrand | 2019-12-10T08:28:26 | Remove documentation URL that is already default | diff --git a/Cargo.toml b/Cargo.toml
index 2a94513..5257e33 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,6 @@ license = "Apache-2.0"
repository = "https://github.com/achanda/ipnetwork"
keywords = ["network", "ip", "address"]
readme = "README.md"
-documentation = "https://docs.rs/ipnetwork/"
categories = ["ne... | 1 | 0 | 1 |
152f1a839333bf61d6230622314637883d81192a | Luca BRUNO | 2019-11-27T17:20:54 | ipnetwork: add netmask constructors
This adds constructors to build all network types from a network
address and network mask pair. | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 6f88053..95e2a27 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -32,6 +32,7 @@ impl Serialize for Ipv4Network {
impl Ipv4Network {
/// Constructs a new `Ipv4Network` from any `Ipv4Addr` and a prefix denoting the network size.
+ ///
/// If the prefix is larger ... | 3 | 75 | 0 |
31fc25f9ce66f02e971ab6a00226e76430c70a5d | Luca BRUNO | 2019-11-27T15:50:47 | cargo: rustfmt whole project | diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs
index 0e3341c..5efd8f0 100644
--- a/benches/parse_bench.rs
+++ b/benches/parse_bench.rs
@@ -3,30 +3,40 @@ use ipnetwork::{Ipv4Network, Ipv6Network};
use std::net::{Ipv4Addr, Ipv6Addr};
fn parse_ipv4_benchmark(c: &mut Criterion) {
- c.bench_function("pa... | 5 | 178 | 56 |
d54f463f86681fac43c891b0870b6bdf81de2d8c | Abhishek Chanda | 2019-11-23T13:48:22 | Uprev for a new release | diff --git a/Cargo.toml b/Cargo.toml
index 33083b4..2a94513 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.15.0" # When updating version, also modify html_root_url in the lib.rs
+version = "0.15.1" # When updating version, also modify html_root_url in the lib.rs
a... | 2 | 2 | 2 |
26706b37902475fb31844c44579d4a4c7283ca66 | Lukas Kalbertodt | 2019-10-30T14:32:11 | Use `slice::iter` instead of `into_iter` to avoid future breakage
`an_array.into_iter()` currently just works because of the autoref
feature, which then calls `<[T] as IntoIterator>::into_iter`. But
in the future, arrays will implement `IntoIterator`, too. In order
to avoid problems in the future, the call is replaced... | diff --git a/src/ipv6.rs b/src/ipv6.rs
index e5667bb..d382161 100644
--- a/src/ipv6.rs
+++ b/src/ipv6.rs
@@ -247,7 +247,7 @@ impl fmt::Display for Ipv6Network {
/// If the mask is invalid this will return an `IpNetworkError::InvalidPrefix`.
pub fn ipv6_mask_to_prefix(mask: Ipv6Addr) -> Result<u8, IpNetworkError> {
... | 1 | 1 | 1 |
9e42aaeb3ec665f676c291af3a547b38c87354f8 | Abhishek Chanda | 2019-09-12T19:25:48 | Uprev for a new release | diff --git a/Cargo.toml b/Cargo.toml
index 83258eb..33083b4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.14.0" # When updating version, also modify html_root_url in the lib.rs
+version = "0.15.0" # When updating version, also modify html_root_url in the lib.rs
a... | 2 | 2 | 2 |
a6dfadc21de2cfe8fb7be688044f9df07255e391 | Linus Färnstrand | 2019-03-25T14:23:21 | Manual import cleanup | diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs
index c880846..0e3341c 100644
--- a/benches/parse_bench.rs
+++ b/benches/parse_bench.rs
@@ -1,10 +1,5 @@
-#[macro_use]
-extern crate criterion;
-
-
+use criterion::{criterion_group, criterion_main, Criterion};
use ipnetwork::{Ipv4Network, Ipv6Network};
-use ... | 6 | 9 | 39 |
61eeb5843f07c5c714b25e7af40abe4142f75c80 | Linus Färnstrand | 2019-03-25T14:15:41 | Run cargo fix --edition-idioms | diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs
index ba2f1c8..c880846 100644
--- a/benches/parse_bench.rs
+++ b/benches/parse_bench.rs
@@ -1,6 +1,6 @@
#[macro_use]
extern crate criterion;
-extern crate ipnetwork;
+
use ipnetwork::{Ipv4Network, Ipv6Network};
use criterion::Criterion;
diff --git a/src... | 6 | 9 | 9 |
d8f3cc199261c626a2631bc81f7241c9edca1a20 | Linus Färnstrand | 2019-03-25T14:15:21 | Upgrade to edition 2018 | diff --git a/Cargo.toml b/Cargo.toml
index 51a3c17..55ad0de 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ keywords = ["network", "ip", "address"]
readme = "README.md"
documentation = "https://docs.rs/ipnetwork/"
categories = ["network-programming", "os"]
+edition = "2018"
[dependencies]
clippy = {vers... | 1 | 1 | 0 |
c2d4b9aeae07c66f90d6d67ef3be737b67716284 | Linus Färnstrand | 2019-03-25T14:13:50 | Run cargo fix --edition | diff --git a/src/common.rs b/src/common.rs
index f2a5274..e925fbd 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -11,7 +11,7 @@ pub enum IpNetworkError {
impl fmt::Display for IpNetworkError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- use IpNetworkError::*;
+ use crate::IpNetwork... | 4 | 7 | 7 |
10d12cd94509f98cbc0d60d9f42380615faee638 | Emīls Piņķis | 2019-02-20T11:07:29 | Deserialize from String rather &str for ipnetwork:Ipv{4,6}Network | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 88a4549..43b3472 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -20,8 +20,8 @@ impl<'de> Deserialize<'de> for Ipv4Network {
where
D: Deserializer<'de>,
{
- let s = <&str>::deserialize(deserializer)?;
- Ipv4Network::from_str(s).map_err(de::Erro... | 2 | 4 | 4 |
e7c85b5b815479d84818d50253ff016b1cfb5e2f | Abhishek Chanda | 2019-02-06T23:29:46 | Implement overlaps for both types | diff --git a/src/ipv4.rs b/src/ipv4.rs
index bd8822c..88a4549 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -72,6 +72,17 @@ impl Ipv4Network {
other.is_subnet_of(self)
}
+ /// Checks if the given `Ipv4Network` is partly contained in other.
+ pub fn overlaps(self, other: Ipv4Network) -> bool {
+ ... | 3 | 43 | 1 |
439a0deeb722b48ce8cf3381380a3177a2ccd9c0 | Abhishek Chanda | 2019-02-06T23:12:47 | Implement is_subnet_of and is_supernet_of | diff --git a/src/ipv4.rs b/src/ipv4.rs
index ec4fa27..bd8822c 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -62,6 +62,16 @@ impl Ipv4Network {
self.prefix
}
+ /// Checks if the given `Ipv4Network` is a subnet of the other.
+ pub fn is_subnet_of(self, other: Ipv4Network) -> bool {
+ other.ip... | 3 | 87 | 0 |
1b06452e889638d8f5bda66ebeeb6b86fa82f320 | Abhishek Chanda | 2019-02-02T23:57:25 | Optimise contains for IPv4 | diff --git a/src/ipv4.rs b/src/ipv4.rs
index 67f49d7..ec4fa27 100644
--- a/src/ipv4.rs
+++ b/src/ipv4.rs
@@ -131,8 +131,8 @@ impl Ipv4Network {
/// assert!(!net.contains(Ipv4Addr::new(127, 0, 1, 70)));
/// ```
pub fn contains(&self, ip: Ipv4Addr) -> bool {
- let net = u32::from(self.network());
- ... | 1 | 2 | 2 |
2b9936fa8e6a92fecfff8a5967e240f721fbdd8a | Abhishek Chanda | 2019-02-02T23:36:08 | Track benchmark for contains | diff --git a/benches/parse_bench.rs b/benches/parse_bench.rs
index f206f83..ba2f1c8 100644
--- a/benches/parse_bench.rs
+++ b/benches/parse_bench.rs
@@ -5,6 +5,8 @@ extern crate ipnetwork;
use ipnetwork::{Ipv4Network, Ipv6Network};
use criterion::Criterion;
+use std::net::{Ipv4Addr, Ipv6Addr};
+
fn parse_ipv4_benc... | 1 | 17 | 1 |
a19f24a9c69732651e465e4207dcb675a71bf60a | Abhishek Chanda | 2019-02-02T21:43:27 | Add a benchmark for CIDR parsing
Also optimise the cidr_parts implementation | diff --git a/Cargo.toml b/Cargo.toml
index 12ebba9..51a3c17 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,7 @@ serde = ">=0.8.0, <2.0"
[dev-dependencies]
serde_json = "1.0"
serde_derive = ">=0.8.0, <2.0"
+criterion = "0.2.9"
[badges]
travis-ci = { repository = "achanda/ipnetwork" }
@@ -24,3 +25,7 @@ trav... | 3 | 41 | 8 |
1f96439a873abe67144dc722c3bf79b9ac0ecf30 | Abhishek Chanda | 2019-02-01T22:16:03 | Prepare new release | diff --git a/Cargo.toml b/Cargo.toml
index b5b6b95..12ebba9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ipnetwork"
-version = "0.13.1" # When updating version, also modify html_root_url in the lib.rs
+version = "0.14.0" # When updating version, also modify html_root_url in the lib.rs
a... | 2 | 2 | 2 |
d8ce2e4dbcd12d101ed9dda5040b7092da12f7ac | Emīls Piņķis | 2019-02-01T11:57:14 | Added custom deserialization and serialization for ipnetwork::IpNetwork | diff --git a/Cargo.toml b/Cargo.toml
index e58a638..b5b6b95 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,10 +13,10 @@ categories = ["network-programming", "os"]
[dependencies]
clippy = {version = "0.0.302", optional = true}
serde = ">=0.8.0, <2.0"
-serde_derive = ">=0.8.0, <2.0"
[dev-dependencies]
serde_json ... | 2 | 37 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.