async_dnssd/lib.rs
1#![doc(html_root_url = "https://docs.rs/async-dnssd/0.5.1")]
2#![warn(missing_docs)]
3#![warn(rust_2018_idioms)]
4#![warn(unused_extern_crates, unused_qualifications)]
5//! # Asynchronous wrapper for DNS-SD C libraries
6//!
7//! Interesting entry points:
8//!
9//! * [Browse for available services][`browse`]
10//! * [Create Connection to register records with][`connect`]
11//! * [Enumerate domains that are recommended for registration or browsing][`enumerate_domains`]
12//! * [Query for an arbitrary DNS record][`query_record`]
13//! * [Register a service][`register`]
14//! * [Add a record to a registered service][`Registration::add_record`]
15//! * [Register record][`Connection::register_record`]
16//! * [Find hostname and port (and more) for a service][`resolve`]
17//!
18//! Also the following things might be interesting:
19//!
20//! * [Purge record from cache][`reconfirm_record`]
21//! * [Construct full name][`FullName::construct`]
22//! * [Stream timeouts][`TimeoutStream`]
23//!
24//! ## Porting from dnssd C API
25//!
26//! | C API | functionality in this crate |
27//! |---------------------------------|--------------------------------------------------------------|
28//! | [`DNSServiceAddRecord`] | [`Registration::add_record`], [`Register::add_record`] |
29//! | [`DNSServiceBrowse`] | [`browse`] |
30//! | [`DNSServiceConstructFullName`] | [`FullName::construct`] |
31//! | [`DNSServiceCreateConnection`] | [`connect`] |
32//! | [`DNSServiceEnumerateDomains`] | [`enumerate_domains`] |
33//! | [`DNSServiceQueryRecord`] | [`query_record`] |
34//! | [`DNSServiceReconfirmRecord`] | [`reconfirm_record`] |
35//! | [`DNSServiceRegister`] | [`register`] |
36//! | [`DNSServiceRegisterRecord`] | [`Connection::register_record`] |
37//! | [`DNSServiceResolve`] | [`resolve`] |
38//! | [`DNSServiceUpdateRecord`] | [`Record::update_record`], [`RegisterRecord::update_record`] |
39//!
40//! The following functions are called automatically when needed:
41//! * [`DNSServiceProcessResult`] driving callbacks (event loop)
42//! * [`DNSServiceRefDeallocate`] called when dropping various resource handles
43//! * [`DNSServiceRefSockFD`] used for integration with tokio (event loop)
44//! * [`DNSServiceRemoveRecord`] called when dropping [`Record`](struct.Record.html)
45//!
46//! The `TXTRecord*` "TXT Record Construction Functions" are not
47//! wrapped; [`TxtRecord`] provides a native rust implementation with
48//! similar functionality.
49//!
50//! [`DNSServiceAddRecord`]: https://developer.apple.com/documentation/dnssd/1804730-dnsserviceaddrecord
51//! [`DNSServiceBrowse`]: https://developer.apple.com/documentation/dnssd/1804742-dnsservicebrowse
52//! [`DNSServiceConstructFullName`]: https://developer.apple.com/documentation/dnssd/1804753-dnsserviceconstructfullname
53//! [`DNSServiceCreateConnection`]: https://developer.apple.com/documentation/dnssd/1804724-dnsservicecreateconnection
54//! [`DNSServiceEnumerateDomains`]: https://developer.apple.com/documentation/dnssd/1804754-dnsserviceenumeratedomains
55//! [`DNSServiceQueryRecord`]: https://developer.apple.com/documentation/dnssd/1804747-dnsservicequeryrecord
56//! [`DNSServiceReconfirmRecord`]: https://developer.apple.com/documentation/dnssd/1804726-dnsservicereconfirmrecord
57//! [`DNSServiceRegister`]: https://developer.apple.com/documentation/dnssd/1804733-dnsserviceregister
58//! [`DNSServiceRegisterRecord`]: https://developer.apple.com/documentation/dnssd/1804727-dnsserviceregisterrecord
59//! [`DNSServiceResolve`]: https://developer.apple.com/documentation/dnssd/1804744-dnsserviceresolve
60//! [`DNSServiceUpdateRecord`]: https://developer.apple.com/documentation/dnssd/1804739-dnsserviceupdaterecord
61//! [`DNSServiceProcessResult`]: https://developer.apple.com/documentation/dnssd/1804696-dnsserviceprocessresult
62//! [`DNSServiceRefDeallocate`]: https://developer.apple.com/documentation/dnssd/1804697-dnsservicerefdeallocate
63//! [`DNSServiceRefSockFD`]: https://developer.apple.com/documentation/dnssd/1804698-dnsservicerefsockfd
64//! [`DNSServiceRemoveRecord`]: https://developer.apple.com/documentation/dnssd/1804736-dnsserviceremoverecord
65//! [`Registration::add_record`]: struct.Registration.html#method.add_record
66//! [`Register::add_record`]: struct.Register.html#method.add_record
67//! [`browse`]: fn.browse.html
68//! [`FullName::construct`]: struct.FullName.html#method.construct
69//! [`connect`]: fn.connect.html
70//! [`enumerate_domains`]: fn.enumerate_domains.html
71//! [`query_record`]: fn.query_record.html
72//! [`reconfirm_record`]: fn.reconfirm_record.html
73//! [`register`]: fn.register.html
74//! [`Connection::register_record`]: struct.Connection.html#method.register_record
75//! [`resolve`]: fn.resolve.html
76//! [`Record::update_record`]: struct.Record.html#method.update_record
77//! [`RegisterRecord::update_record`]: struct.RegisterRecord.html#method.update_record
78//! [`TimeoutStream`]: struct.TimeoutStream.html
79//! [`TxtRecord`]: struct.TxtRecord.html
80
81pub use self::{
82 dns_consts::{
83 Class,
84 Type,
85 },
86 error::Error,
87 ffi::MAX_DOMAIN_NAME,
88 interface::{
89 Interface,
90 InterfaceIndex,
91 },
92 service::*,
93 timeout_stream::{
94 StreamTimeoutExt,
95 TimeoutStream,
96 },
97 txt_record::{
98 TxtRecord,
99 TxtRecordError,
100 TxtRecordIter,
101 },
102};
103
104mod cstr;
105mod dns_consts;
106mod error;
107mod evented;
108mod ffi;
109mod fused_err_stream;
110mod future;
111mod inner;
112mod interface;
113mod non_exhaustive_struct;
114mod notify;
115mod service;
116mod stream;
117mod timeout_stream;
118mod txt_record;
119
120fn init() {
121 #[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
122 {
123 use std::sync::Once;
124
125 static INIT: Once = Once::new();
126 INIT.call_once(|| {
127 const AVAHI_COMPAT_NOWARN: &str = "AVAHI_COMPAT_NOWARN";
128 if std::env::var_os(AVAHI_COMPAT_NOWARN).is_none() {
129 std::env::set_var(AVAHI_COMPAT_NOWARN, "1");
130 }
131 });
132 }
133}