Skip to main content

hick_reactor/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(not(test), forbid(unsafe_code))]
3#![cfg_attr(test, deny(unsafe_code))]
4#![deny(missing_docs)]
5#![cfg_attr(docsrs, feature(doc_cfg))]
6#![cfg_attr(docsrs, allow(unused_attributes))]
7
8mod command;
9mod discovery;
10mod driver;
11mod endpoint;
12mod error;
13mod options;
14mod proto;
15mod query;
16mod service;
17#[cfg(all(test, feature = "tracing", not(miri)))]
18mod trace_cov;
19
20pub use discovery::{Lookup, QueryParam, ServiceEntry};
21pub use endpoint::Endpoint;
22pub use error::{CancelError, RegisterError, ServerError, StartQueryError};
23pub use options::ServerOptions;
24pub use query::{Query, QueryEvent};
25pub use service::Service;
26
27// Re-export the mdns-proto types callers need to interact with this crate.
28pub use mdns_proto::{
29  CollectedAnswer, EndpointConfig, Name, QueryHandle, QuerySpec, ServiceHandle, ServiceRecords,
30  ServiceRenamed, ServiceSpec, ServiceUpdate, config, error as proto_error, event, wire,
31};
32
33/// Per-runtime adapter for the [`tokio`] runtime.
34#[cfg(feature = "tokio")]
35#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
36pub mod tokio {
37  use crate::options::ServerOptions;
38
39  /// `tokio`-backed mDNS [`Endpoint`](crate::Endpoint).
40  pub type Endpoint = crate::Endpoint;
41
42  /// Construct an mDNS endpoint pinned to the `tokio` runtime.
43  ///
44  /// Equivalent to [`crate::Endpoint::server::<agnostic_net::tokio::Net>`].
45  #[inline]
46  pub async fn server(opts: ServerOptions) -> Result<Endpoint, crate::ServerError> {
47    Endpoint::server::<agnostic_net::tokio::Net>(opts).await
48  }
49}
50
51/// Per-runtime adapter for the [`smol`] runtime.
52#[cfg(feature = "smol")]
53#[cfg_attr(docsrs, doc(cfg(feature = "smol")))]
54pub mod smol {
55  use crate::options::ServerOptions;
56
57  /// `smol`-backed mDNS [`Endpoint`](crate::Endpoint).
58  pub type Endpoint = crate::Endpoint;
59
60  /// Construct an mDNS endpoint pinned to the `smol` runtime.
61  ///
62  /// Equivalent to [`crate::Endpoint::server::<agnostic_net::smol::Net>`].
63  #[inline]
64  pub async fn server(opts: ServerOptions) -> Result<Endpoint, crate::ServerError> {
65    Endpoint::server::<agnostic_net::smol::Net>(opts).await
66  }
67}