diff --git a/Cargo.lock b/Cargo.lock index 25def720b..7498f25b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6469,7 +6469,6 @@ dependencies = [ "shuttle-codegen", "shuttle-common", "sqlx", - "sync_wrapper", "thiserror", "thruster", "tide", diff --git a/service/Cargo.toml b/service/Cargo.toml index 261d85514..2379c1e4a 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -31,7 +31,6 @@ salvo = { version = "0.37.5", optional = true } serde_json = { workspace = true } serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"], optional = true } poise = { version = "0.5.2", optional = true } -sync_wrapper = { version = "0.1.1", optional = true } thiserror = { workspace = true } thruster = { version = "1.3.0", optional = true } tide = { version = "0.16.0", optional = true } @@ -70,7 +69,7 @@ codegen = ["shuttle-codegen/frameworks"] loader = ["cargo", "libloading"] web-actix-web = ["actix-web", "num_cpus"] -web-axum = ["axum", "sync_wrapper"] +web-axum = ["axum"] web-rocket = ["rocket"] web-thruster = ["thruster"] web-tide = ["tide", "async-std"] diff --git a/service/src/lib.rs b/service/src/lib.rs index b40fe8b61..d65961515 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -509,7 +509,7 @@ impl Service for T where T: poem::Endpoint + Sync + Send + 'static, { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { poem::Server::new(poem::listener::TcpListener::bind(addr)) .run(self) .await @@ -529,7 +529,7 @@ where T: Send + Sync + Clone + 'static + warp::Filter, T::Extract: warp::reply::Reply, { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { warp::serve(*self).run(addr).await; Ok(()) } @@ -540,12 +540,10 @@ pub type ShuttleWarp = Result, Error>; #[cfg(feature = "web-axum")] #[async_trait] -impl Service for sync_wrapper::SyncWrapper { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { - let router = self.into_inner(); - +impl Service for axum::Router { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { axum::Server::bind(&addr) - .serve(router.into_make_service()) + .serve(self.into_make_service()) .await .map_err(error::CustomError::new)?; @@ -553,13 +551,16 @@ impl Service for sync_wrapper::SyncWrapper { } } +#[cfg(feature = "web-axum")] +pub type ShuttleAxum = Result; + #[cfg(feature = "web-actix-web")] #[async_trait] impl Service for F where F: FnOnce(&mut actix_web::web::ServiceConfig) + Sync + Send + Clone + 'static, { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), Error> { // Start a worker for each cpu, but no more than 4. let worker_count = num_cpus::get().max(4); @@ -575,13 +576,10 @@ where #[cfg(feature = "web-actix-web")] pub type ShuttleActixWeb = Result; -#[cfg(feature = "web-axum")] -pub type ShuttleAxum = Result, Error>; - #[cfg(feature = "web-salvo")] #[async_trait] impl Service for salvo::Router { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { salvo::Server::new(salvo::listener::TcpListener::bind(addr)) .serve(self) .await; @@ -599,7 +597,7 @@ impl Service for T where T: thruster::ThrusterServer + Sync + Send + 'static, { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { self.build(&addr.ip().to_string(), addr.port()).await; Ok(()) @@ -615,7 +613,7 @@ impl Service for tide::Server where T: Clone + Send + Sync + 'static, { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { self.listen(addr).await.map_err(error::CustomError::new)?; Ok(()) @@ -637,7 +635,7 @@ where T::Error: std::error::Error + Send + Sync, T::Future: std::future::Future + Send + Sync, { - async fn bind(mut self: Box, addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> { let shared = tower::make::Shared::new(self); hyper::Server::bind(&addr) .serve(shared) @@ -651,7 +649,7 @@ where #[cfg(feature = "bot-serenity")] #[async_trait] impl Service for serenity::Client { - async fn bind(mut self: Box, _addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, _addr: SocketAddr) -> Result<(), error::Error> { self.start().await.map_err(error::CustomError::new)?; Ok(()) @@ -668,7 +666,7 @@ where T: std::marker::Send + std::marker::Sync + 'static, E: std::marker::Send + std::marker::Sync + 'static, { - async fn bind(mut self: Box, _addr: SocketAddr) -> Result<(), error::Error> { + async fn bind(mut self, _addr: SocketAddr) -> Result<(), error::Error> { self.start().await.map_err(error::CustomError::new)?; Ok(())