use std::future::Future;
use crate::application::Result;
use crate::application::ty::Application;
use crate::axum::ServiceExt;
use crate::axum::serve::Listener;
impl Application<()> {
pub async fn serve<L>(self, listener: L) -> Result<()>
where
L: Listener,
L::Addr: std::fmt::Debug,
{
let service = crate::pipeline::assemble::into_service(self);
crate::axum::serve(listener, service.into_make_service())
.await
.map_err(|source| crate::EngineError::Serve { source })
}
pub async fn serve_with_shutdown<L, F>(self, listener: L, signal: F) -> Result<()>
where
L: Listener,
L::Addr: std::fmt::Debug,
F: Future<Output = ()> + Send + 'static,
{
let service = crate::pipeline::assemble::into_service(self);
crate::axum::serve(listener, service.into_make_service())
.with_graceful_shutdown(signal)
.await
.map_err(|source| crate::EngineError::Serve { source })
}
}