use h3_util::server::H3Acceptor;
pub struct H3Router(tonic::service::Routes);
impl H3Router {
pub fn new(routes: tonic::service::Routes) -> Self {
Self(routes)
}
}
impl H3Router {
pub async fn serve_with_shutdown<AC, F>(
self,
acceptor: AC,
signal: F,
) -> Result<(), crate::Error>
where
AC: H3Acceptor,
F: std::future::Future<Output = ()>,
{
let auxm_router = axum_h3::H3Router::from(self.0.prepare().into_axum_router());
auxm_router.serve_with_shutdown(acceptor, signal).await
}
pub async fn serve<AC>(self, acceptor: AC) -> Result<(), crate::Error>
where
AC: H3Acceptor,
{
self.serve_with_shutdown(acceptor, async {
futures::future::pending().await
})
.await
}
}