dns_sd_native/lib.rs
1#![warn(missing_docs)]
2#![warn(unused_extern_crates, unused_qualifications)]
3
4//! Access the operating system's built-in
5//! [DNS-SD](https://en.wikipedia.org/wiki/Zero-configuration_networking#DNS-based_service_discovery) /
6//! [mDNS](https://en.wikipedia.org/wiki/Multicast_DNS) stack for service registration.
7//!
8//! This crate provides a cross-platform async API (using [Tokio](https://tokio.rs)) for
9//! registering DNS-SD services via the native OS facilities:
10//!
11//! - **macOS**: native [DNS-SD framework](https://developer.apple.com/documentation/dnssd) (available since macOS 10.12)
12//! - **Windows**: native [Win32 DNS-SD API](https://learn.microsoft.com/en-us/uwp/api/windows.networking.servicediscovery.dnssd?view=winrt-28000) (available since Windows 10)
13//! - **Linux/FreeBSD**: [Avahi](https://avahi.org) via D-Bus (no binary dependency on libavahi)
14//!
15//! **Note:** This crate currently supports _registration_ of services only, not browsing/discovery.
16//!
17//! # Example
18//!
19//! ```no_run
20//! use dns_sd_native::ServiceRegistrationBuilder;
21//!
22//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
23//! let service = ServiceRegistrationBuilder::new("_http._tcp", 8080)
24//! .name("My Web Server")
25//! .register()
26//! .await?;
27//!
28//! // Service is now discoverable on the network.
29//! // It will be automatically unregistered when dropped,
30//! // or you can unregister explicitly:
31//! service.unregister().await?;
32//! # Ok(())
33//! # }
34//! ```
35
36pub use self::register::*;
37
38mod register;
39
40#[cfg(all(unix, not(target_os = "macos")))]
41mod linux;
42#[cfg(target_os = "macos")]
43mod macos;
44#[cfg(target_os = "windows")]
45mod windows;