From dfab84c5ed56b91a4f3d83a41b00ec94969ddd88 Mon Sep 17 00:00:00 2001 From: Rudi Floren Date: Thu, 5 Feb 2026 18:47:17 +0100 Subject: [PATCH] add ease of use impls for check cd elements --- src/contact/check.rs | 15 +++++++++++++++ src/domain/check.rs | 15 +++++++++++++++ src/host/check.rs | 15 +++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/contact/check.rs b/src/contact/check.rs index 1a30a78..6b62be6 100644 --- a/src/contact/check.rs +++ b/src/contact/check.rs @@ -60,6 +60,21 @@ pub struct CheckedContact { pub reason: Option, } +impl CheckedContact { + /// Returns a tuple of the availability and reason (if any) for the contact id + pub fn available(&self) -> (bool, Option<&str>) { + ( + self.id.available, + self.reason.as_ref().map(|r| r.value.as_str()), + ) + } + + /// Returns the contact id value + pub fn id(&self) -> &str { + &self.id.value + } +} + #[derive(Debug, FromXml)] #[xml(rename = "reason", ns(XMLNS))] pub struct Reason { diff --git a/src/domain/check.rs b/src/domain/check.rs index 57f7f99..65a0eb6 100644 --- a/src/domain/check.rs +++ b/src/domain/check.rs @@ -59,6 +59,21 @@ pub struct CheckedDomain { pub reason: Option, } +impl CheckedDomain { + /// Returns a tuple of the availability and reason (if any) for the domain name + pub fn available(&self) -> (bool, Option<&str>) { + ( + self.name.available, + self.reason.as_ref().map(|r| r.value.as_str()), + ) + } + + /// Returns the domain name value + pub fn name(&self) -> &str { + &self.name.value + } +} + #[derive(Debug, FromXml)] #[xml(rename = "reason", ns(XMLNS))] pub struct Reason { diff --git a/src/host/check.rs b/src/host/check.rs index 9665316..c28bdd0 100644 --- a/src/host/check.rs +++ b/src/host/check.rs @@ -62,6 +62,21 @@ pub struct CheckedHost { pub reason: Option, } +impl CheckedHost { + /// Returns a tuple of the availability and reason (if any) for the host name + pub fn available(&self) -> (bool, Option<&str>) { + ( + self.name.available, + self.reason.as_ref().map(|r| r.value.as_str()), + ) + } + + /// Returns the host name value + pub fn name(&self) -> &str { + &self.name.value + } +} + #[derive(Debug, FromXml)] #[xml(rename = "reason", ns(XMLNS))] pub struct Reason {