rdap 0.2.0

A modern RDAP (Registration Data Access Protocol) client
Documentation
//! Common RDAP structures shared across all object types.
//!
//! Defines [`Link`], [`Notice`] (also used as `Remark`), [`Event`],
//! [`PublicId`], and the [`Status`] / [`Remark`] type aliases.

use serde::{Deserialize, Serialize};

/// A link to a related resource (RFC 7483 Section 4.2).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Link {
    /// Context URI — the value of the link context.
    #[serde(default)]
    pub value: Option<String>,

    /// Link relation type (e.g. `"self"`, `"related"`, `"alternate"`).
    #[serde(default)]
    pub rel: Option<String>,

    /// Target URI of the link.
    pub href: String,

    /// Languages of the target resource (BCP 47 tags).
    #[serde(default)]
    pub hreflang: Vec<String>,

    /// Human-readable title of the link.
    #[serde(default)]
    pub title: Option<String>,

    /// Media type hint for the target (e.g. `"screen"`, `"print"`).
    #[serde(default)]
    pub media: Option<String>,

    /// MIME type of the target resource (e.g. `"application/rdap+json"`).
    #[serde(rename = "type", default)]
    pub link_type: Option<String>,
}

/// A notice or remark attached to an RDAP response (RFC 7483 Section 4.3).
///
/// Notices appear at the top level of a response; remarks appear within
/// individual objects. Both share the same structure.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Notice {
    /// Short summary of the notice (e.g. `"Terms of Use"`).
    #[serde(default)]
    pub title: Option<String>,

    /// Notice type identifier (e.g. `"result set truncated due to authorization"`).
    #[serde(rename = "type", default)]
    pub notice_type: Option<String>,

    /// Body text of the notice (one string per paragraph).
    #[serde(default)]
    pub description: Vec<String>,

    /// Links related to this notice (e.g. terms-of-service URL).
    #[serde(default)]
    pub links: Vec<Link>,
}

/// A lifecycle event for an RDAP object (RFC 7483 Section 4.5).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Event {
    /// Event action type (e.g. `"registration"`, `"expiration"`, `"last changed"`).
    #[serde(rename = "eventAction")]
    pub action: String,

    /// Handle of the actor responsible for the event, if any.
    #[serde(rename = "eventActor", default)]
    pub actor: Option<String>,

    /// Date and time of the event (ISO 8601 / RFC 3339).
    #[serde(rename = "eventDate")]
    pub date: String,

    /// Links related to this event.
    #[serde(default)]
    pub links: Vec<Link>,
}

/// A public identifier for an RDAP object (RFC 7483 Section 4.8).
///
/// For example, an IANA Registrar ID: `{ type: "IANA Registrar ID", identifier: "376" }`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PublicId {
    /// Type of the public identifier (e.g. `"IANA Registrar ID"`).
    #[serde(rename = "type")]
    pub id_type: String,

    /// Value of the public identifier.
    pub identifier: String,
}

/// Status values for an RDAP object (e.g. `"active"`, `"locked"`).
pub type Status = Vec<String>;

/// Remark — same structure as [`Notice`], used within individual objects.
pub type Remark = Notice;