Skip to main content

Overview

The RdapObject enum represents all possible RDAP response types. It is returned by query methods and contains the parsed RDAP data.

Definition

pub enum RdapObject {
    Domain(Domain),
    Entity(Entity),
    Nameserver(Nameserver),
    Autnum(Autnum),
    IpNetwork(IpNetwork),
    Error(ErrorResponse),
    DomainSearch(DomainSearchResults),
    EntitySearch(EntitySearchResults),
    NameserverSearch(NameserverSearchResults),
    Help(HelpResponse),
}

Object Types

Domain

Domain name registration information. Returned By: Domain and TLD queries Structure:
object_class_name
String
Always “domain” for domain objects
conformance
Vec<String>
RDAP conformance levels (e.g., [“rdap_level_0”])
ldh_name
Option<String>
Letters-Digits-Hyphen (ASCII) domain name
unicode_name
Option<String>
Unicode (IDN) domain name if different from ldh_name
handle
Option<String>
Registry-unique identifier for the domain
nameservers
Vec<Nameserver>
Authoritative nameservers for this domain
secure_dns
Option<SecureDNS>
DNSSEC information including DS records and DNSKEY data
entities
Vec<Entity>
Associated entities (registrant, admin, tech, registrar, etc.)
status
Status
Domain status codes (e.g., clientTransferProhibited, active)
events
Vec<Event>
Lifecycle events (registration, expiration, last updated, etc.)
Related links including registrar referrals
notices
Vec<Notice>
Informational notices from the server
remarks
Vec<Remark>
Additional remarks about the domain
public_ids
Vec<PublicId>
Public identifiers
port43
Option<String>
Legacy WHOIS server hostname
lang
Option<String>
Language tag for the response
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Domain, "example.com");
let result = client.query(&request).await?;

if let RdapObject::Domain(domain) = result {
    println!("Domain: {:?}", domain.ldh_name);
    println!("Status: {:?}", domain.status);
    
    for event in &domain.events {
        println!("Event: {} at {:?}", event.event_action, event.event_date);
    }
    
    for ns in &domain.nameservers {
        println!("Nameserver: {:?}", ns.ldh_name);
    }
    
    for entity in &domain.entities {
        println!("Entity: {:?} ({:?})", entity.handle, entity.roles);
    }
}

Entity

Entity (organization, person, contact) information. Returned By: Entity queries, nested in Domain/IP/AS responses Structure:
object_class_name
String
Always “entity” for entity objects
handle
Option<String>
Registry-unique identifier for the entity
vcard_array
Option<VCard>
Contact information in jCard/vCard format
roles
Vec<String>
Entity roles (registrant, administrative, technical, registrar, abuse, etc.)
public_ids
Vec<PublicId>
Public identifiers
entities
Vec<Entity>
Nested entities
status
Status
Entity status codes
events
Vec<Event>
Lifecycle events
Related links
notices
Vec<Notice>
Informational notices
remarks
Vec<Remark>
Additional remarks
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Entity, "ENTITY-123");
let result = client.query(&request).await?;

if let RdapObject::Entity(entity) = result {
    println!("Handle: {:?}", entity.handle);
    println!("Roles: {:?}", entity.roles);
    
    if let Some(vcard) = &entity.vcard_array {
        // Parse vCard data for contact info
    }
}

Nameserver

Nameserver information. Returned By: Nameserver queries, nested in Domain responses Structure:
object_class_name
String
Always “nameserver” for nameserver objects
ldh_name
Option<String>
ASCII hostname of the nameserver
unicode_name
Option<String>
Unicode hostname if different from ldh_name
handle
Option<String>
Registry-unique identifier
ip_addresses
Option<IpAddresses>
IPv4 and IPv6 addresses of the nameserver
entities
Vec<Entity>
Associated entities
status
Status
Nameserver status codes
events
Vec<Event>
Lifecycle events
Related links
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Nameserver, "ns1.example.com");
let result = client.query(&request).await?;

if let RdapObject::Nameserver(ns) = result {
    println!("Nameserver: {:?}", ns.ldh_name);
    
    if let Some(ips) = &ns.ip_addresses {
        println!("IPv4: {:?}", ips.v4);
        println!("IPv6: {:?}", ips.v6);
    }
}

Autnum

Autonomous System Number information. Returned By: AS number queries Structure:
object_class_name
String
Always “autnum” for AS number objects
handle
Option<String>
Registry-unique identifier
start_autnum
Option<u32>
Start of AS number range
end_autnum
Option<u32>
End of AS number range (same as start for single AS)
name
Option<String>
AS name/description
type_
Option<String>
AS type (e.g., “DIRECT ALLOCATION”, “DIRECT ASSIGNMENT”)
country
Option<String>
Country code (ISO 3166-1 alpha-2)
entities
Vec<Entity>
Associated entities (registrant, abuse contact, etc.)
status
Status
AS status codes
events
Vec<Event>
Lifecycle events
Related links
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Autnum, "AS15169");
let result = client.query(&request).await?;

if let RdapObject::Autnum(autnum) = result {
    println!("AS: {} - {}", autnum.start_autnum?, autnum.end_autnum?);
    println!("Name: {:?}", autnum.name);
    println!("Country: {:?}", autnum.country);
    
    for entity in &autnum.entities {
        if entity.roles.contains(&"abuse".to_string()) {
            println!("Abuse contact: {:?}", entity.handle);
        }
    }
}

IpNetwork

IP address or network registration information. Returned By: IP address queries Structure:
object_class_name
String
Always “ip network” for IP network objects
handle
Option<String>
Registry-unique identifier
start_address
Option<String>
Start IP address of the range
end_address
Option<String>
End IP address of the range
ip_version
Option<String>
IP version (“v4” or “v6”)
name
Option<String>
Network name
type_
Option<String>
Network type (e.g., “DIRECT ALLOCATION”, “ASSIGNED PA”)
country
Option<String>
Country code (ISO 3166-1 alpha-2)
parent_handle
Option<String>
Handle of parent network (for suballocations)
entities
Vec<Entity>
Associated entities (registrant, abuse contact, etc.)
status
Status
Network status codes
events
Vec<Event>
Lifecycle events
Related links
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Ip, "8.8.8.8");
let result = client.query(&request).await?;

if let RdapObject::IpNetwork(network) = result {
    println!("Network: {} - {}", 
        network.start_address.unwrap_or_default(),
        network.end_address.unwrap_or_default()
    );
    println!("Version: {:?}", network.ip_version);
    println!("Name: {:?}", network.name);
    println!("Country: {:?}", network.country);
    
    for entity in &network.entities {
        if entity.roles.contains(&"abuse".to_string()) {
            println!("Abuse contact found");
        }
    }
}

Error

Error response from RDAP server. Returned By: Server errors (non-404 HTTP errors) Structure:
error_code
Option<u16>
HTTP error code
title
Option<String>
Error title/summary
description
Option<Vec<String>>
Detailed error description lines
lang
Option<String>
Language tag for the error message
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Domain, "invalid");

match client.query(&request).await {
    Ok(RdapObject::Error(error)) => {
        println!("Error {}: {:?}", 
            error.error_code.unwrap_or(0),
            error.title
        );
        if let Some(desc) = error.description {
            for line in desc {
                println!("  {}", line);
            }
        }
    }
    Err(e) => println!("Error: {}", e),
    _ => {}
}

DomainSearch

Domain search results. Returned By: Domain search queries Structure:
conformance
Vec<String>
RDAP conformance levels
notices
Vec<Notice>
Informational notices
domains
Vec<Domain>
Array of matching domain objects
lang
Option<String>
Language tag for the response
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};
use url::Url;

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::DomainSearch, "example*")
    .with_server(Url::parse("https://rdap.verisign.com/com/v1/")?);
let result = client.query(&request).await?;

if let RdapObject::DomainSearch(search) = result {
    println!("Found {} domains", search.domains.len());
    
    for domain in search.domains {
        println!("  - {:?}", domain.ldh_name);
    }
}

EntitySearch

Entity search results. Returned By: Entity search queries Structure:
conformance
Vec<String>
RDAP conformance levels
notices
Vec<Notice>
Informational notices
entities
Vec<Entity>
Array of matching entity objects
lang
Option<String>
Language tag for the response
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};
use url::Url;

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::EntitySearch, "Example*")
    .with_server(Url::parse("https://rdap.arin.net/registry/")?);
let result = client.query(&request).await?;

if let RdapObject::EntitySearch(search) = result {
    println!("Found {} entities", search.entities.len());
    
    for entity in search.entities {
        println!("  - {:?} ({:?})", entity.handle, entity.roles);
    }
}

NameserverSearch

Nameserver search results. Returned By: Nameserver search queries Structure:
conformance
Vec<String>
RDAP conformance levels
notices
Vec<Notice>
Informational notices
nameservers
Vec<Nameserver>
Array of matching nameserver objects
lang
Option<String>
Language tag for the response
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};
use url::Url;

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::NameserverSearch, "ns*.example.com")
    .with_server(Url::parse("https://rdap.verisign.com/com/v1/")?);
let result = client.query(&request).await?;

if let RdapObject::NameserverSearch(search) = result {
    println!("Found {} nameservers", search.nameservers.len());
    
    for ns in search.nameservers {
        println!("  - {:?}", ns.ldh_name);
    }
}

Help

RDAP server help response. Returned By: Help queries Structure:
conformance
Vec<String>
RDAP conformance levels supported by the server
notices
Vec<Notice>
Help information and notices from the server
lang
Option<String>
Language tag for the response
Example:
use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};
use url::Url;

let client = RdapClient::new()?;
let request = RdapRequest::new(QueryType::Help, "")
    .with_server(Url::parse("https://rdap.verisign.com/com/v1/")?);
let result = client.query(&request).await?;

if let RdapObject::Help(help) = result {
    println!("Conformance: {:?}", help.conformance);
    
    for notice in help.notices {
        if let Some(title) = notice.title {
            println!("Notice: {}", title);
        }
        for desc in notice.description {
            println!("  {}", desc);
        }
    }
}

Pattern Matching

Use Rust’s pattern matching to handle different response types:
use rdap::{RdapClient, RdapRequest, RdapObject};

let client = RdapClient::new()?;
let query_type = RdapRequest::detect_type("example.com")?;
let request = RdapRequest::new(query_type, "example.com");
let result = client.query(&request).await?;

match result {
    RdapObject::Domain(domain) => {
        println!("Domain: {:?}", domain.ldh_name);
    }
    RdapObject::IpNetwork(network) => {
        println!("IP Network: {} - {}",
            network.start_address.unwrap_or_default(),
            network.end_address.unwrap_or_default()
        );
    }
    RdapObject::Autnum(autnum) => {
        println!("AS{}: {:?}", 
            autnum.start_autnum.unwrap_or(0),
            autnum.name
        );
    }
    RdapObject::Entity(entity) => {
        println!("Entity: {:?}", entity.handle);
    }
    RdapObject::Nameserver(ns) => {
        println!("Nameserver: {:?}", ns.ldh_name);
    }
    RdapObject::Error(error) => {
        println!("Error: {:?}", error.title);
    }
    RdapObject::DomainSearch(search) => {
        println!("Found {} domains", search.domains.len());
    }
    RdapObject::EntitySearch(search) => {
        println!("Found {} entities", search.entities.len());
    }
    RdapObject::NameserverSearch(search) => {
        println!("Found {} nameservers", search.nameservers.len());
    }
    RdapObject::Help(help) => {
        println!("Help: {:?}", help.conformance);
    }
}

Build docs developers (and LLMs) love