Skip to content

Commit

Permalink
draft: a new struct for attributes of a resolve service
Browse files Browse the repository at this point in the history
  • Loading branch information
keepsimple1 committed Feb 9, 2025
1 parent fba8025 commit 9f54e37
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/service_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,18 @@ impl ServiceInfo {
.cloned()
.unwrap_or(ServiceStatus::Unknown)
}

/// Returns a resolved service instance.
pub fn as_resolved_service(self) -> ResolvedService {
ResolvedService {
ty_domain: self.ty_domain,
fullname: self.fullname,
host: self.server,
port: self.port,
addresses: self.addresses,
txt_properties: self.txt_properties,
}
}
}

/// Removes potentially duplicated ".local." at the end of "hostname".
Expand Down Expand Up @@ -1086,6 +1098,16 @@ pub(crate) fn split_sub_domain(domain: &str) -> (&str, Option<&str>) {
}
}

#[non_exhaustive]
pub struct ResolvedService {
pub ty_domain: String,
pub fullname: String,
pub host: String,
pub port: u16,
pub addresses: HashSet<IpAddr>,
pub txt_properties: TxtProperties,
}

#[cfg(test)]
mod tests {
use super::{
Expand Down

0 comments on commit 9f54e37

Please sign in to comment.