agnostic/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(not(feature = "std"), no_std)]
3#![deny(warnings, missing_docs)]
4#![cfg_attr(docsrs, feature(doc_cfg))]
5#![cfg_attr(docsrs, allow(unused_attributes))]
6#![allow(clippy::needless_return)]
7#![allow(unreachable_code)]
8
9#[cfg(all(feature = "alloc", not(feature = "std")))]
10extern crate alloc as std;
11
12#[cfg(feature = "std")]
13extern crate std;
14
15pub use runtime::*;
16
17/// The runtime related traits and types
18mod runtime {
19  pub use agnostic_lite::{
20    AfterHandle, AfterHandleError, AsyncAfterSpawner, AsyncBlockingSpawner, AsyncLocalSpawner,
21    AsyncSpawner, JoinHandle, LocalJoinHandle, RuntimeLite, Yielder, cfg_linux, cfg_smol,
22    cfg_tokio, cfg_unix, cfg_windows, time,
23  };
24
25  /// Runtime trait
26  pub trait Runtime: RuntimeLite {
27    /// The network abstraction for this runtime
28    #[cfg(feature = "net")]
29    #[cfg_attr(docsrs, doc(cfg(feature = "net")))]
30    type Net: super::net::Net;
31
32    /// The process abstraction for this runtime
33    #[cfg(feature = "process")]
34    #[cfg_attr(docsrs, doc(cfg(feature = "process")))]
35    type Process: super::process::Process;
36
37    /// The Quinn abstraction for this runtime
38    #[cfg(feature = "quinn")]
39    #[cfg_attr(docsrs, doc(cfg(feature = "quinn")))]
40    type Quinn: super::quinn::QuinnRuntime;
41
42    /// Returns the runtime for [`quinn`](::quinn)
43    #[cfg(feature = "quinn")]
44    #[cfg_attr(docsrs, doc(cfg(feature = "quinn")))]
45    fn quinn() -> Self::Quinn;
46  }
47}
48
49/// Traits, helpers, and type definitions for asynchronous I/O functionality.
50pub use agnostic_io as io;
51
52/// [`tokio`] runtime adapter
53///
54/// [`tokio`]: https://docs.rs/tokio
55#[cfg(feature = "tokio")]
56#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
57pub mod tokio;
58
59/// [`smol`] runtime adapter
60///
61/// [`smol`]: https://docs.rs/smol
62#[cfg(feature = "smol")]
63#[cfg_attr(docsrs, doc(cfg(feature = "smol")))]
64pub mod smol;
65
66/// Network related traits
67#[cfg(feature = "net")]
68#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
69pub mod net;
70
71/// Agnostic async DNS provider.
72#[cfg(feature = "dns")]
73#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
74pub mod dns {
75  pub use agnostic_dns::{
76    AgnosticTime, AsyncConnectionProvider, AsyncDnsUdp, AsyncRuntimeProvider, AsyncSpawn,
77    CLOUDFLARE_IPS, Dns, GOOGLE_IPS, LookupIpStrategy, NameServerConfig, NameServerConfigGroup,
78    Protocol, QUAD9_IPS, ResolverConfig, ResolverOpts, ServerOrderingStrategy, Timer,
79    read_system_conf,
80  };
81
82  #[cfg(feature = "dns-over-rustls")]
83  #[cfg_attr(docsrs, doc(cfg(feature = "dns-over-rustls")))]
84  pub use agnostic_dns::TlsClientConfig;
85
86  #[cfg(unix)]
87  #[cfg_attr(docsrs, doc(cfg(unix)))]
88  pub use agnostic_dns::{parse_resolv_conf, read_resolv_conf};
89}
90
91/// Quinn related traits
92#[cfg(feature = "quinn")]
93#[cfg_attr(docsrs, doc(cfg(feature = "quinn")))]
94pub mod quinn;
95
96/// Process related traits
97#[cfg(feature = "process")]
98#[cfg_attr(docsrs, doc(cfg(feature = "process")))]
99pub mod process;