Skip to content

Commit

Permalink
From IpAddr for DnsContent
Browse files Browse the repository at this point in the history
  • Loading branch information
ToroidalFox committed Jun 8, 2024
1 parent 2b1e12a commit 483d201
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cloudflare/src/endpoints/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::framework::{OrderDirection, SearchMatch};
use chrono::offset::Utc;
use chrono::DateTime;
use serde::{Deserialize, Serialize};
use std::net::{Ipv4Addr, Ipv6Addr};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

/// List DNS Records
/// <https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records>
Expand Down Expand Up @@ -174,6 +174,15 @@ pub enum DnsContent {
SRV { content: String },
}

impl<T: Into<IpAddr>> From<T> for DnsContent {
fn from(value: T) -> Self {
match value.into() {
IpAddr::V4(content) => Self::A { content },
IpAddr::V6(content) => Self::AAAA { content },
}
}
}

#[derive(Deserialize, Debug)]
pub struct DeleteDnsRecordResponse {
/// DNS record identifier tag
Expand Down

0 comments on commit 483d201

Please sign in to comment.