technitium 0.4.0

Typed async Rust client for the Technitium DNS Server API
Documentation
use serde::{Deserialize, Serialize};

/// The type of a DNS zone.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ZoneType {
    /// A primary (authoritative) zone.
    Primary,
    /// A secondary zone that replicates from a primary.
    Secondary,
    /// A stub zone.
    Stub,
    /// A forwarder zone.
    Forwarder,
    /// A secondary forwarder zone.
    SecondaryForwarder,
    /// A catalog zone.
    Catalog,
    /// A secondary catalog zone.
    SecondaryCatalog,
}

impl std::fmt::Display for ZoneType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Primary => write!(f, "Primary"),
            Self::Secondary => write!(f, "Secondary"),
            Self::Stub => write!(f, "Stub"),
            Self::Forwarder => write!(f, "Forwarder"),
            Self::SecondaryForwarder => write!(f, "SecondaryForwarder"),
            Self::Catalog => write!(f, "Catalog"),
            Self::SecondaryCatalog => write!(f, "SecondaryCatalog"),
        }
    }
}

/// A DNS zone managed by the Technitium server.
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Zone {
    /// The zone domain name (e.g., "example.com").
    pub name: String,
    /// The zone type.
    #[serde(rename = "type")]
    pub zone_type: ZoneType,
    /// Whether the zone is disabled.
    #[serde(default)]
    pub disabled: bool,
    /// Whether this is an internal zone.
    #[serde(default)]
    pub internal: bool,
}

/// Response wrapper for zone listing.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ZoneListResponse {
    pub zones: Vec<Zone>,
}

/// Response wrapper for zone creation.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ZoneCreateResponse {
    pub domain: Option<String>,
}

/// Zone configuration options.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ZoneOptions {
    /// Zone transfer allowed networks.
    #[serde(default)]
    pub zone_transfer_allowed_networks: Vec<String>,
    /// Notify name servers.
    #[serde(default)]
    pub notify_name_servers: Vec<String>,
}