Autnum
Represents Autonomous System Number (ASN) information returned from RDAP queries.
Always “autnum” for AS number objects
RDAP conformance levels (e.g., ["rdap_level_0"])
Registry-unique identifier for the AS allocationlet as_handle = autnum.handle.unwrap_or_default();
First AS number in the rangeif let Some(asn) = autnum.start_autnum {
println!("AS{}", asn);
}
Last AS number in the range (usually same as start_autnum for single AS allocations)if autnum.start_autnum == autnum.end_autnum {
println!("Single AS allocation");
} else {
println!("AS range: {} - {}",
autnum.start_autnum.unwrap_or(0),
autnum.end_autnum.unwrap_or(0)
);
}
IP version supported (“v4”, “v6”, or both)
AS name or descriptionprintln!("AS Name: {}", autnum.name.as_deref().unwrap_or("N/A"));
AS status values (e.g., “active”, “reserved”)
ISO 3166-1 alpha-2 country code where AS is registeredif let Some(country) = &autnum.country {
println!("Country: {}", country);
}
Related entities (registrants, technical contacts, abuse contacts). See Entity// Find abuse contact
let abuse = autnum.entities.iter()
.find(|e| e.roles.contains(&"abuse".to_string()))
.and_then(|e| e.vcard.as_ref())
.and_then(|v| v.email());
if let Some(email) = abuse {
println!("Abuse: {}", email);
}
WHOIS server hostname for port 43 queries
Lifecycle events (allocation, last update, etc.). See common fields// Find allocation date
let allocated = autnum.events.iter()
.find(|e| e.action == "registration")
.map(|e| &e.date);
Language tag (e.g., “en”, “fr”)
Example Usage
use rdap_client::RdapClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = RdapClient::new();
// Query an AS number (with or without "AS" prefix)
let result = client.query("15169").await?;
// or: client.query("AS15169").await?;
if let Some(autnum) = result.autnum() {
// Display AS information
if let Some(asn) = autnum.start_autnum {
println!("AS{}", asn);
}
println!("Name: {}", autnum.name.as_deref().unwrap_or("N/A"));
println!("Country: {}", autnum.country.as_deref().unwrap_or("N/A"));
// Show status
if !autnum.status.is_empty() {
println!("Status: {}", autnum.status.join(", "));
}
// Find and display contacts
for entity in &autnum.entities {
if let Some(vcard) = &entity.vcard {
let roles = entity.roles.join(", ");
println!("{}:", roles);
if let Some(name) = vcard.name() {
println!(" Name: {}", name);
}
if let Some(email) = vcard.email() {
println!(" Email: {}", email);
}
}
}
// Show allocation date
for event in &autnum.events {
if event.action == "registration" {
println!("Allocated: {}", event.date);
}
if event.action == "last changed" {
println!("Last updated: {}", event.date);
}
}
}
Ok(())
}
use rdap_client::RdapClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = RdapClient::new();
let result = client.query("15169").await?;
if let Some(autnum) = result.autnum() {
// Find abuse contact entity
for entity in &autnum.entities {
if entity.roles.contains(&"abuse".to_string()) {
if let Some(vcard) = &entity.vcard {
println!("Abuse Contact:");
if let Some(name) = vcard.name() {
println!(" Name: {}", name);
}
if let Some(email) = vcard.email() {
println!(" Email: {}", email);
}
if let Some(tel) = vcard.tel() {
println!(" Phone: {}", tel);
}
}
}
}
}
Ok(())
}