From 483d201fcf6ca4fbeeccf13522ac1e20ea6ffffb Mon Sep 17 00:00:00 2001 From: ToroidalFox <93528864+ToroidalFox@users.noreply.github.com> Date: Sat, 8 Jun 2024 09:29:15 +0900 Subject: [PATCH] From IpAddr for DnsContent --- cloudflare/src/endpoints/dns.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cloudflare/src/endpoints/dns.rs b/cloudflare/src/endpoints/dns.rs index 871945ff..164b09e4 100644 --- a/cloudflare/src/endpoints/dns.rs +++ b/cloudflare/src/endpoints/dns.rs @@ -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 /// @@ -174,6 +174,15 @@ pub enum DnsContent { SRV { content: String }, } +impl> From 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