Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/contact/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ pub struct CheckedContact {
pub reason: Option<Reason>,
}

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 {
Expand Down
15 changes: 15 additions & 0 deletions src/domain/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ pub struct CheckedDomain {
pub reason: Option<Reason>,
}

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 {
Expand Down
15 changes: 15 additions & 0 deletions src/host/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ pub struct CheckedHost {
pub reason: Option<Reason>,
}

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 {
Expand Down