Refactor
Signed-off-by: Walker Crouse <walker.crouse@coop.co.uk>
This commit is contained in:
parent
5df68533da
commit
4314369bf6
@ -1,7 +1,8 @@
|
|||||||
//! Trait definition for cross-platform browser
|
//! Trait definition for cross-platform browser
|
||||||
|
|
||||||
use crate::{EventLoop, NetworkInterface, Result, ServiceDiscoveredCallback};
|
use crate::{EventLoop, NetworkInterface, Result};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Interface for interacting with underlying mDNS implementation service browsing capabilities.
|
/// Interface for interacting with underlying mDNS implementation service browsing capabilities.
|
||||||
pub trait TMdnsBrowser {
|
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.
|
/// Starts the browser. Returns an `EventLoop` which can be called to keep the browser alive.
|
||||||
fn browse_services(&mut self) -> Result<EventLoop>;
|
fn browse_services(&mut self) -> Result<EventLoop>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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<ServiceDiscovery>, Option<Arc<dyn Any>>);
|
||||||
|
|
||||||
|
/// 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,
|
||||||
|
}
|
||||||
|
@ -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<ServiceDiscovery>, Option<Arc<dyn Any>>);
|
|
||||||
|
|
||||||
/// 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,
|
|
||||||
}
|
|
@ -129,7 +129,6 @@ extern crate derive_new;
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
extern crate maplit;
|
extern crate maplit;
|
||||||
|
|
||||||
mod discovery;
|
|
||||||
mod registration;
|
mod registration;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
@ -151,7 +150,7 @@ pub mod linux;
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub mod macos;
|
pub mod macos;
|
||||||
|
|
||||||
pub use discovery::*;
|
pub use browser::{ServiceDiscoveredCallback, ServiceDiscovery};
|
||||||
pub use interface::*;
|
pub use interface::*;
|
||||||
pub use registration::*;
|
pub use registration::*;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user