parse_ripe_delegated

Function parse_ripe_delegated 

Source
pub fn parse_ripe_delegated(content: &str) -> Vec<IpRange>
Expand description

Parse RIPE NCC “delegated-*” statistics content into allocation ranges.

This parser is intentionally simple:

  • Ignores comment lines (#...) and summary/header lines starting with 2.
  • Accepts only ipv4 and ipv6 records.
  • Keeps the two-letter country code exactly as present in the file.

For IPv4 records, count is the number of addresses. For IPv6 records, RIPE encodes the prefix length in the “count” field; this function converts it to an address count.

§Examples

use offline_ripe_geoip::parse_ripe_delegated;

let data = "ripencc|DE|ipv4|46.4.0.0|256|20250101|allocated\n";
let ranges = parse_ripe_delegated(data);
assert_eq!(ranges.len(), 1);
assert_eq!(ranges[0].country, "DE");

§Notes

This does not validate that the returned ranges are non-overlapping or sorted.