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 {