1#![warn(missing_docs)]
14
15pub mod accept;
16pub mod bind;
17mod client;
18mod connect;
19mod crypto;
20mod error;
21#[cfg(any(feature = "quinn", feature = "noq", feature = "quiche", feature = "tcp"))]
22pub mod failover;
23#[cfg(feature = "jemalloc")]
24pub mod jemalloc;
25mod log;
26#[cfg(feature = "noq")]
27pub mod noq;
28pub mod quic;
29#[cfg(feature = "quinn")]
30pub mod quinn;
31mod reconnect;
32mod server;
33#[cfg(feature = "tcp")]
34pub mod tcp;
35pub mod tls;
36#[cfg(all(feature = "uds", unix))]
37pub mod unix;
38mod util;
39#[cfg(feature = "watch")]
40pub mod watch;
41#[cfg(feature = "websocket")]
42pub mod websocket;
43
44pub use client::{Client, ClientConfig};
47pub use connect::ConnectError;
48pub use error::{Error, Result};
49pub use log::Log;
50pub use reconnect::{Backoff, ConnectionStatsReader, Reconnect, Status};
51pub use server::{Request, Server, ServerConfig, Transport};
52
53pub(crate) fn spawn_session((session, driver): (moq_net::Session, moq_net::Driver)) -> moq_net::Session {
60 tokio::spawn(driver);
61 session
62}
63
64pub use moq_net;
66pub use rustls;
67
68#[cfg(feature = "watch")]
71pub use notify;
72
73#[cfg(target_os = "android")]
76pub use jni;
77
78#[cfg(feature = "quiche")]
79pub mod quiche;
80
81#[cfg(feature = "iroh")]
82pub mod iroh;
83
84#[derive(Clone, Debug, clap::ValueEnum, serde::Serialize, serde::Deserialize)]
86#[serde(rename_all = "lowercase")]
87#[non_exhaustive]
88pub enum QuicBackend {
89 #[cfg(feature = "quinn")]
91 Quinn,
92
93 #[cfg(feature = "quiche")]
95 Quiche,
96
97 #[cfg(feature = "noq")]
99 Noq,
100}
101
102impl std::str::FromStr for QuicBackend {
106 type Err = String;
107
108 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
109 <Self as clap::ValueEnum>::from_str(s, true)
110 }
111}
112
113impl QuicBackend {
114 pub fn compiled() -> &'static [Self] {
122 &[
123 #[cfg(feature = "quinn")]
124 Self::Quinn,
125 #[cfg(feature = "quiche")]
126 Self::Quiche,
127 #[cfg(feature = "noq")]
128 Self::Noq,
129 ]
130 }
131
132 pub fn as_str(&self) -> &'static str {
136 match *self {
137 #[cfg(feature = "quinn")]
138 Self::Quinn => "quinn",
139 #[cfg(feature = "quiche")]
140 Self::Quiche => "quiche",
141 #[cfg(feature = "noq")]
142 Self::Noq => "noq",
143 }
144 }
145}
146
147pub fn qlog_supported() -> bool {
152 cfg!(feature = "qlog")
153}
154
155fn default_quic_backend() -> QuicBackend {
156 #[cfg(feature = "quinn")]
157 {
158 QuicBackend::Quinn
159 }
160 #[cfg(all(feature = "noq", not(feature = "quinn")))]
161 {
162 QuicBackend::Noq
163 }
164 #[cfg(all(feature = "quiche", not(feature = "quinn"), not(feature = "noq")))]
165 {
166 QuicBackend::Quiche
167 }
168 #[cfg(all(not(feature = "quiche"), not(feature = "quinn"), not(feature = "noq")))]
169 panic!("no QUIC backend compiled; enable noq, quinn, or quiche feature");
170}
171
172#[cfg(test)]
173mod tests {
174 #[cfg(feature = "quinn")]
175 #[test]
176 fn quinn_is_the_default_backend() {
177 assert!(matches!(super::default_quic_backend(), super::QuicBackend::Quinn));
178 }
179}