From a3932bfce165bd2876c51b0e6fc9aff94d06da29 Mon Sep 17 00:00:00 2001 From: Walker Crouse Date: Fri, 26 Jul 2024 17:55:36 -0400 Subject: [PATCH] remove AsCChars from linux; more clone_from replacements Signed-off-by: Walker Crouse --- zeroconf/src/avahi/browser.rs | 2 +- zeroconf/src/avahi/service.rs | 2 +- zeroconf/src/ffi/c_str.rs | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/zeroconf/src/avahi/browser.rs b/zeroconf/src/avahi/browser.rs index b4e4be5..c10fccd 100644 --- a/zeroconf/src/avahi/browser.rs +++ b/zeroconf/src/avahi/browser.rs @@ -91,7 +91,7 @@ impl TMdnsBrowser for AvahiMdnsBrowser { .build()?, )?)); - self.context.client = self.client.clone(); + self.context.client.clone_from(&self.client); unsafe { if let Err(e) = create_browser(&mut self.context) { diff --git a/zeroconf/src/avahi/service.rs b/zeroconf/src/avahi/service.rs index 444fdde..1d3ac82 100644 --- a/zeroconf/src/avahi/service.rs +++ b/zeroconf/src/avahi/service.rs @@ -127,7 +127,7 @@ impl TMdnsService for AvahiMdnsService { .build()?, )?)); - self.context.client = self.client.clone(); + self.context.client.clone_from(&self.client); unsafe { if let Err(e) = create_service(&mut self.context) { diff --git a/zeroconf/src/ffi/c_str.rs b/zeroconf/src/ffi/c_str.rs index bbb01b0..acde68c 100644 --- a/zeroconf/src/ffi/c_str.rs +++ b/zeroconf/src/ffi/c_str.rs @@ -4,11 +4,13 @@ use libc::c_char; use std::ffi::{CStr, CString}; /// Helper trait to map to `Option<*const c_char>`. +#[cfg(not(target_os = "linux"))] pub trait AsCChars { /// Maps the type to a `Option<*const c_char>`. fn as_c_chars(&self) -> Option<*const c_char>; } +#[cfg(not(target_os = "linux"))] impl AsCChars for Option<&CString> { fn as_c_chars(&self) -> Option<*const c_char> { self.map(|s| s.as_ptr() as *const c_char)