1 unstable release
0.1.0 | May 26, 2023 |
---|
#7 in #bgpkit
5KB
asnames-rs
Simple Autonomous System (AS) names and country lookup Rust library
Data source
Data definition
#[derive(Debug, Clone)]
pub struct AsName {
pub asn: u32,
pub name: String,
pub country: String,
}
Usage
use std::collections::HashMap;
use asnames::{AsName, load_asnames};
let asnames: HashMap<u32, AsName> = load_asnames().unwrap();
assert_eq!(asnames.get(&3333).unwrap().name, "RIPE-NCC-AS Reseaux IP Europeens Network Coordination Centre (RIPE NCC)");
assert_eq!(asnames.get(&400644).unwrap().name, "BGPKIT-LLC");
assert_eq!(asnames.get(&400644).unwrap().country, "US");
lib.rs
:
asnames-rs is a library for simple Autonomous System (AS) names and country lookup
Data source
Data structure
#[derive(Debug, Clone)]
pub struct AsName {
pub asn: u32,
pub name: String,
pub country: String,
}
Example
use std::collections::HashMap;
use asnames::{AsName, load_asnames};
let asnames: HashMap<u32, AsName> = load_asnames().unwrap();
assert_eq!(asnames.get(&3333).unwrap().name, "RIPE-NCC-AS Reseaux IP Europeens Network Coordination Centre (RIPE NCC)");
assert_eq!(asnames.get(&400644).unwrap().name, "BGPKIT-LLC");
assert_eq!(asnames.get(&400644).unwrap().country, "US");
Dependencies
~4–15MB
~229K SLoC