ngyn_shuttle/
lib.rs

1use ngyn_hyper::HyperApplication;
2use shuttle_runtime::{CustomError, Error};
3use std::net::SocketAddr;
4
5pub type ShuttleApplication = HyperApplication;
6pub struct NgynService(HyperApplication);
7
8#[shuttle_runtime::async_trait]
9impl shuttle_runtime::Service for NgynService {
10    /// Takes the app that is returned by the user in their [shuttle_runtime::main] function
11    /// and binds to an address passed in by shuttle.
12    async fn bind(mut self, addr: SocketAddr) -> Result<(), Error> {
13        let _ = self
14            .0
15            .listen(addr)
16            .await
17            .map_err(|err| CustomError::new::<Error>(err.into()))?;
18        Ok(())
19    }
20}
21
22impl From<HyperApplication> for NgynService {
23    fn from(app: HyperApplication) -> Self {
24        Self(app)
25    }
26}
27
28pub type ShuttleNgyn = Result<NgynService, Error>;