pub use tokio_quiche;
pub use tokio_quiche::quiche;
mod buffer;
mod conn;
mod connector;
mod driver;
mod endpoint;
mod error;
mod listener;
mod stream;
use bytes::Bytes;
pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub(crate) fn ensure_readable_file(path: &str, label: &str) -> Result<(), Error> {
let meta = std::fs::metadata(path).map_err(|e| -> Error {
format!("quiche-h3: {label} {path:?} is not accessible: {e}").into()
})?;
if !meta.is_file() {
return Err(format!("quiche-h3: {label} {path:?} is not a regular file").into());
}
std::fs::File::open(path).map_err(|e| -> Error {
format!("quiche-h3: {label} {path:?} is not readable: {e}").into()
})?;
Ok(())
}
pub(crate) fn ensure_nonempty_alpn(
settings: &tokio_quiche::settings::QuicSettings,
label: &str,
) -> Result<(), Error> {
if settings.alpn.is_empty() {
return Err(format!("quiche-h3: {label} has an empty ALPN list").into());
}
Ok(())
}
pub use connector::{H3QuicheClientConfig, H3QuicheConnector};
pub use endpoint::H3QuicheEndpoint;
pub use listener::{H3QuicheAcceptor, H3QuicheServerConfig, DEFAULT_MAX_IN_FLIGHT_HANDSHAKES};
pub use stream::{Connection, H3RecvStream, H3SendStream, H3Stream, StreamOpener};
const _: fn() = || {
fn assert_h3_conn<C: h3::quic::Connection<Bytes>>() {}
assert_h3_conn::<Connection<Bytes>>();
fn assert_clone_send_static<T: Clone + Send + 'static>() {}
assert_clone_send_static::<H3QuicheConnector>();
fn assert_clone_send_sync<T: Clone + Send + Sync + 'static>() {}
assert_clone_send_sync::<H3QuicheEndpoint>();
fn accept_yields_connection(a: &mut H3QuicheAcceptor) {
fn is_accept_result(
_: impl std::future::Future<Output = Result<Option<Connection<Bytes>>, Error>>,
) {
}
is_accept_result(a.accept());
}
fn connect_yields_connection(c: &H3QuicheConnector) {
fn is_connect_result(
_: impl std::future::Future<Output = Result<Connection<Bytes>, Error>>,
) {
}
is_connect_result(c.connect());
}
let _ = accept_yields_connection;
let _ = connect_yields_connection;
};