1#![doc = include_str!("../README.md")]
2
3pub use poem;
4
5pub struct PoemService<T>(pub T);
7
8#[shuttle_runtime::async_trait]
9impl<T> shuttle_runtime::Service for PoemService<T>
10where
11 T: poem::Endpoint + Send + 'static,
12{
13 async fn bind(mut self, addr: std::net::SocketAddr) -> Result<(), shuttle_runtime::Error> {
14 poem::Server::new(poem::listener::TcpListener::bind(addr))
15 .run(self.0)
16 .await
17 .map_err(shuttle_runtime::CustomError::new)?;
18
19 Ok(())
20 }
21}
22
23impl<T> From<T> for PoemService<T>
24where
25 T: poem::Endpoint + Send + 'static,
26{
27 fn from(router: T) -> Self {
28 Self(router)
29 }
30}
31
32#[doc = include_str!("../README.md")]
33pub type ShuttlePoem<T> = Result<PoemService<T>, shuttle_runtime::Error>;