diff --git a/src/service_info.rs b/src/service_info.rs index 061cb48..56dfcce 100644 --- a/src/service_info.rs +++ b/src/service_info.rs @@ -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 { - 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 { + self.properties + .into_iter() + .map(|p| { + ( + p.key, + p.val + .map_or_else(String::new, |v| String::from_utf8(v).unwrap_or_default()), + ) + }) + .collect() } }