pub use crate::os::{BrowseError, ServiceBrowser};
use std::collections::HashMap;
pub type Result<T, E = BrowseError> = std::result::Result<T, E>;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ServiceEventType {
Added,
Removed,
}
#[derive(Debug)]
pub struct Service {
pub name: String,
pub regtype: String,
pub interface_index: Option<u32>,
pub domain: String,
pub event_type: ServiceEventType,
pub hostname: String,
pub port: u16,
pub txt_record: Option<HashMap<String, String>>,
}
pub struct ServiceBrowserBuilder {
pub(crate) regtype: String,
pub(crate) domain: Option<String>,
}
impl ServiceBrowserBuilder {
pub fn new(regtype: &str) -> ServiceBrowserBuilder {
ServiceBrowserBuilder {
regtype: String::from(regtype),
domain: None,
}
}
pub fn with_domain(mut self, domain: &str) -> ServiceBrowserBuilder {
self.domain = Some(String::from(domain));
self
}
pub fn browse(self) -> Result<ServiceBrowser> {
crate::os::browse(self)
}
}