rdap 0.2.0

A modern RDAP (Registration Data Access Protocol) client
Documentation
//! RDAP data models
//!
//! Typed representations of every RDAP response object defined in
//! [RFC 7483](https://tools.ietf.org/html/rfc7483), plus search result
//! wrappers and the jCard/vCard contact model.

pub mod autnum;
pub mod common;
pub mod domain;
pub mod entity;
pub mod error;
pub mod ip_network;
pub mod nameserver;
pub mod search;
pub mod vcard;

pub use autnum::Autnum;
pub use common::*;
pub use domain::Domain;
pub use entity::Entity;
pub use error::ErrorResponse;
pub use ip_network::IpNetwork;
pub use nameserver::Nameserver;
pub use search::*;
pub use vcard::VCard;

use serde::{Deserialize, Serialize};

/// Top-level RDAP response object.
///
/// Every successful RDAP query is parsed into one of these variants.
/// The variant is determined by the `objectClassName` field in the JSON
/// response, or by the presence of search-result or error keys.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RdapObject {
    /// A domain name registration (objectClassName = `"domain"`).
    Domain(Domain),
    /// An entity (person, organization, or role) (objectClassName = `"entity"`).
    Entity(Entity),
    /// A DNS nameserver (objectClassName = `"nameserver"`).
    Nameserver(Nameserver),
    /// An Autonomous System Number allocation (objectClassName = `"autnum"`).
    Autnum(Autnum),
    /// An IP address network (objectClassName = `"ip network"`).
    IpNetwork(IpNetwork),
    /// An RDAP error response (contains `errorCode`).
    Error(ErrorResponse),
    /// Domain search results (contains `domainSearchResults`).
    DomainSearch(DomainSearchResults),
    /// Entity search results (contains `entitySearchResults`).
    EntitySearch(EntitySearchResults),
    /// Nameserver search results (contains `nameserverSearchResults`).
    NameserverSearch(NameserverSearchResults),
    /// An RDAP help/server-info response (fallback when no other type matches).
    Help(HelpResponse),
}

/// Response to an RDAP `/help` query.
///
/// Contains server conformance information and optional notices but no
/// registration data.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HelpResponse {
    /// RDAP conformance extensions supported by the server (e.g. `"rdap_level_0"`).
    #[serde(rename = "rdapConformance", default)]
    pub conformance: Vec<String>,

    /// Server notices (terms of service, rate limits, etc.).
    #[serde(default)]
    pub notices: Vec<Notice>,

    /// Language tag of the response (BCP 47).
    #[serde(default)]
    pub lang: Option<String>,
}