tonic_h3/lib.rs
1//! gRPC over HTTP/3 for Rust.
2//! # Examples
3//! Server example:
4//! ```ignore
5//! async fn run_server(endpoint: h3_quinn::quinn::Endpoint) -> Result<(), tonic_h3::Error> {
6//! let router = tonic::transport::Server::builder()
7//! .add_service(GreeterServer::new(HelloWorldService {}));
8//! let acceptor = tonic_h3::quinn::H3QuinnAcceptor::new(endpoint.clone());
9//! tonic_h3::server::H3Router::from(router)
10//! .serve(acceptor)
11//! .await?;
12//! endpoint.wait_idle().await;
13//! Ok(())
14//! }
15//! ```
16//! Client example:
17//! ```ignore
18//! async fn run_client(
19//! uri: http::Uri,
20//! client_endpoint: quinn::Endpoint,
21//! ) -> Result<(), tonic_h3::Error> {
22//! let channel = tonic_h3::quinn::new_quinn_h3_channel(uri.clone(), client_endpoint.clone());
23//! let mut client = crate::greeter_client::GreeterClient::new(channel);
24//! let request = tonic::Request::new(crate::HelloRequest {
25//! name: "Tonic".into(),
26//! });
27//! let response = client.say_hello(request).await?;
28//! println!("RESPONSE={:?}", response);
29//! Ok(())
30//! }
31//!```
32
33mod client;
34pub mod server;
35pub use client::H3Channel;
36
37pub type Error = Box<dyn std::error::Error + Send + Sync>;
38
39// Reexport quinn implementation
40#[cfg(feature = "quinn")]
41pub mod quinn {
42 pub use h3_util::quinn::*;
43}
44
45#[cfg(feature = "msquic")]
46pub mod msquic {
47 pub use h3_util::msquic::*;
48}
49
50#[cfg(feature = "s2n-quic")]
51pub mod s2n {
52 pub use h3_util::s2n::*;
53}