diff --git a/zeroconf/src/macos/service.rs b/zeroconf/src/macos/service.rs index e36f08b..545c227 100644 --- a/zeroconf/src/macos/service.rs +++ b/zeroconf/src/macos/service.rs @@ -97,6 +97,12 @@ impl BonjourMdnsService { pub fn register(&mut self) -> Result { debug!("Registering service: {:?}", self); + let txt_len = self + .txt_record + .as_ref() + .map(|t| t.0.get_length()) + .unwrap_or(0); + let txt_record = self .txt_record .as_ref() @@ -112,7 +118,7 @@ impl BonjourMdnsService { .domain(self.domain.as_ref().as_c_chars().unwrap_or_null()) .host(self.host.as_ref().as_c_chars().unwrap_or_null()) .port(self.port) - .txt_len(self.txt_record.as_ref().map(|t| t.size()).unwrap_or(0)) + .txt_len(txt_len) .txt_record(txt_record) .callback(Some(register_callback)) .context(self.context as *mut c_void) diff --git a/zeroconf/src/macos/txt_record.rs b/zeroconf/src/macos/txt_record.rs index 05f9331..5b14a60 100644 --- a/zeroconf/src/macos/txt_record.rs +++ b/zeroconf/src/macos/txt_record.rs @@ -87,11 +87,6 @@ impl BonjourTxtRecord { Box::new(Values(Iter::new(self))) } - /// Returns the size of the raw bytes in the TXT record. - pub fn size(&self) -> u16 { - self.0.get_length() - } - /// Returns a new `HashMap` with this record's keys and values. pub fn to_map(&self) -> HashMap { let mut m = HashMap::new();