Skip to content

Commit

Permalink
redo the new API
Browse files Browse the repository at this point in the history
  • Loading branch information
keepsimple1 committed Feb 6, 2025
1 parent 067d51f commit 03885c0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/service_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,17 @@ impl TxtProperties {
}

/// Returns a map of properties, where the key is the property key.
pub fn get_property_map_str(&self) -> HashMap<String, String> {
let mut map = HashMap::new();
for prop in self.properties.iter() {
map.insert(prop.key.clone(), prop.val_str().to_string());
}
map
pub fn into_property_map_str(self) -> HashMap<String, String> {
self.properties
.into_iter()
.map(|p| {
(
p.key,
p.val
.map_or_else(String::new, |v| String::from_utf8(v).unwrap_or_default()),
)
})
.collect()
}
}

Expand Down

0 comments on commit 03885c0

Please sign in to comment.