diff --git a/zeroconf/src/browser.rs b/zeroconf/src/browser.rs index cbfd4dc..00c62b9 100644 --- a/zeroconf/src/browser.rs +++ b/zeroconf/src/browser.rs @@ -1,7 +1,8 @@ //! Trait definition for cross-platform browser -use crate::{EventLoop, NetworkInterface, Result, ServiceDiscoveredCallback}; +use crate::{EventLoop, NetworkInterface, Result}; use std::any::Any; +use std::sync::Arc; /// Interface for interacting with underlying mDNS implementation service browsing capabilities. pub trait TMdnsBrowser { @@ -30,3 +31,25 @@ pub trait TMdnsBrowser { /// Starts the browser. Returns an `EventLoop` which can be called to keep the browser alive. fn browse_services(&mut self) -> Result; } + +/// Callback invoked from [`MdnsBrowser`] once a service has been discovered and resolved. +/// +/// # Arguments +/// * `discovered_service` - The service that was disovered +/// * `context` - The optional user context passed through +/// +/// [`MdnsBrowser`]: type.MdnsBrowser.html +pub type ServiceDiscoveredCallback = dyn Fn(Result, Option>); + +/// Represents a service that has been discovered by a [`MdnsBrowser`]. +/// +/// [`MdnsBrowser`]: type.MdnsBrowser.html +#[derive(Debug, Getters, Builder, BuilderDelegate, Serialize, Deserialize, Clone, PartialEq, Eq)] +pub struct ServiceDiscovery { + name: String, + kind: String, + domain: String, + host_name: String, + address: String, + port: u16, +} diff --git a/zeroconf/src/discovery.rs b/zeroconf/src/discovery.rs deleted file mode 100644 index 28b42ed..0000000 --- a/zeroconf/src/discovery.rs +++ /dev/null @@ -1,25 +0,0 @@ -use super::Result; -use std::any::Any; -use std::sync::Arc; - -/// Callback invoked from [`MdnsBrowser`] once a service has been discovered and resolved. -/// -/// # Arguments -/// * `discovered_service` - The service that was disovered -/// * `context` - The optional user context passed through -/// -/// [`MdnsBrowser`]: type.MdnsBrowser.html -pub type ServiceDiscoveredCallback = dyn Fn(Result, Option>); - -/// Represents a service that has been discovered by a [`MdnsBrowser`]. -/// -/// [`MdnsBrowser`]: type.MdnsBrowser.html -#[derive(Debug, Getters, Builder, BuilderDelegate, Serialize, Deserialize, Clone, PartialEq, Eq)] -pub struct ServiceDiscovery { - name: String, - kind: String, - domain: String, - host_name: String, - address: String, - port: u16, -} diff --git a/zeroconf/src/lib.rs b/zeroconf/src/lib.rs index 86279bd..78f6bb3 100644 --- a/zeroconf/src/lib.rs +++ b/zeroconf/src/lib.rs @@ -129,7 +129,6 @@ extern crate derive_new; #[allow(unused_imports)] extern crate maplit; -mod discovery; mod registration; #[macro_use] mod macros; @@ -151,7 +150,7 @@ pub mod linux; #[cfg(target_os = "macos")] pub mod macos; -pub use discovery::*; +pub use browser::{ServiceDiscoveredCallback, ServiceDiscovery}; pub use interface::*; pub use registration::*;