diff --git a/CHANGELOG.md b/CHANGELOG.md index 8188d28..5c1e00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [0.2.0] - 2025-01-24 + +### Changed +- axum upgraded from 0.7 to 0.8 +- feature `axum-07` as been removed in favor of feature `axum-08` + ## [0.1.0] - 2024-12-26 ### Added diff --git a/Cargo.lock b/Cargo.lock index 7aea58b..ec29076 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,7 +84,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.4.5", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit 0.7.3", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" +dependencies = [ + "axum-core 0.5.0", "bytes", "futures-util", "http", @@ -93,7 +119,7 @@ dependencies = [ "hyper", "hyper-util", "itoa", - "matchit", + "matchit 0.8.4", "memchr", "mime", "percent-encoding", @@ -127,6 +153,25 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.74" @@ -676,6 +721,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "memchr" version = "2.7.4" @@ -1292,7 +1343,7 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.7.9", "base64", "bytes", "h2", @@ -1470,7 +1521,7 @@ dependencies = [ name = "twurst-error" version = "0.1.0" dependencies = [ - "axum-core", + "axum-core 0.5.0", "http", "serde", "serde_json", @@ -1494,7 +1545,7 @@ dependencies = [ name = "twurst-example-server" version = "0.0.0" dependencies = [ - "axum", + "axum 0.8.1", "prost", "prost-reflect", "prost-types", @@ -1508,7 +1559,7 @@ dependencies = [ name = "twurst-integration" version = "0.0.0" dependencies = [ - "axum", + "axum 0.8.1", "eyre", "prost", "prost-reflect", @@ -1528,7 +1579,7 @@ dependencies = [ name = "twurst-server" version = "0.1.0" dependencies = [ - "axum", + "axum 0.8.1", "http-body-util", "pin-project-lite", "prost", diff --git a/Cargo.toml b/Cargo.toml index 231d8e5..1feeb7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,13 @@ [workspace] -members = ["build", "client", "error", "server", "integration", "example/server", "example/client"] +members = [ + "build", + "client", + "error", + "server", + "integration", + "example/server", + "example/client", +] resolver = "2" [workspace.package] @@ -9,8 +17,8 @@ license = "Apache-2.0" rust-version = "1.79" [workspace.dependencies] -axum = { version = "0.7.9", default-features = false } -axum-core-04 = { package = "axum-core", version = "0.4.5" } +axum = { version = "0.8", default-features = false } +axum-core-05 = { package = "axum-core", version = "0.5.0" } eyre = "0.6.10" http = "1" http-body = "1" @@ -31,8 +39,8 @@ tonic = { version = "0.12.3", default-features = false } tonic-012 = { package = "tonic", version = "0.12.3", default-features = false } tonic-build = "0.12.3" tower-service = "0.3.3" -tower = "0.5.1" +tower = "0.5.2" tower-http = "0.6.2" tracing = "0.1.35" trait-variant = "0.1.2" -twurst-error = { path = "error", version = "0.1.0" } +twurst-error = { path = "error", version = "0.2.0" } diff --git a/build/Cargo.toml b/build/Cargo.toml index 6a26331..94ad0b5 100644 --- a/build/Cargo.toml +++ b/build/Cargo.toml @@ -3,7 +3,7 @@ name = "twurst-build" description = "Build script to generate bindings for .proto files for Twirp" repository = "https://github.com/helsing-ai/twurst" documentation = "https://docs.rs/twurst-build" -version = "0.1.0" +version = "0.2.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/build/src/lib.rs b/build/src/lib.rs index 3d9d2b2..2a9d522 100644 --- a/build/src/lib.rs +++ b/build/src/lib.rs @@ -352,10 +352,10 @@ impl TwirpServiceGenerator { write!(buf, "| {{")?; writeln!(buf, " async move {{")?; write!(buf, " service.{}(request", method.name)?; - for _ in 0..self.request_extractors.len() { + for (_name, type_name) in &self.request_extractors { write!( buf, - ", match ::twurst_server::codegen::FromRequestParts::from_request_parts(&mut parts, &state).await {{ Ok(r) => r, Err(e) => {{ return Err(::twurst_server::codegen::twirp_error_from_response(e).await) }} }}" + ", match <{type_name} as ::twurst_server::codegen::FromRequestParts<_>>::from_request_parts(&mut parts, &state).await {{ Ok(r) => r, Err(e) => {{ return Err(::twurst_server::codegen::twirp_error_from_response(e).await) }} }}" )?; } writeln!(buf, ").await")?; @@ -407,10 +407,10 @@ impl TwirpServiceGenerator { write!(buf, "Ok(Box::into_pin(")?; } write!(buf, "service.{}(request", method.name)?; - for _ in 0..self.request_extractors.len() { + for (_name, type_name) in &self.request_extractors { write!( buf, - ", match ::twurst_server::codegen::FromRequestParts::from_request_parts(&mut parts, &()).await {{ Ok(r) => r, Err(e) => {{ return Err(::twurst_server::codegen::twirp_error_from_response(e).await) }} }}" + ", match <{type_name} as ::twurst_server::codegen::FromRequestParts<_>>::from_request_parts(&mut parts, &()).await {{ Ok(r) => r, Err(e) => {{ return Err(::twurst_server::codegen::twirp_error_from_response(e).await) }} }}" )?; } write!(buf, ").await")?; diff --git a/client/Cargo.toml b/client/Cargo.toml index a9974ef..edff1f7 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -4,7 +4,7 @@ description = "Twirp client related code" keywords = ["Twirp"] repository = "https://github.com/helsing-ai/twurst" documentation = "https://docs.rs/twurst-client" -version = "0.1.0" +version = "0.2.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/error/Cargo.toml b/error/Cargo.toml index 0660098..d74b21d 100644 --- a/error/Cargo.toml +++ b/error/Cargo.toml @@ -3,20 +3,20 @@ name = "twurst-error" description = "Twirp error struct" repository = "https://github.com/helsing-ai/twurst" documentation = "https://docs.rs/twurst-error" -version = "0.1.0" +version = "0.2.0" authors.workspace = true edition.workspace = true license.workspace = true rust-version.workspace = true [features] -axum-07 = ["dep:axum-core-04", "http"] +axum-08 = ["dep:axum-core-05", "http"] http = ["dep:http", "dep:serde_json", "serde"] serde = ["dep:serde"] tonic-012 = ["dep:tonic-012"] [dependencies] -axum-core-04 = { workspace = true, optional = true } +axum-core-05 = { workspace = true, optional = true } http = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"], optional = true } serde_json = { workspace = true, optional = true } diff --git a/error/src/lib.rs b/error/src/lib.rs index 77b83df..209d29a 100644 --- a/error/src/lib.rs +++ b/error/src/lib.rs @@ -336,10 +336,10 @@ impl> From> for TwirpError { } } -#[cfg(feature = "axum-07")] -impl axum_core_04::response::IntoResponse for TwirpError { +#[cfg(feature = "axum-08")] +impl axum_core_05::response::IntoResponse for TwirpError { #[inline] - fn into_response(self) -> axum_core_04::response::Response { + fn into_response(self) -> axum_core_05::response::Response { self.into() } } diff --git a/integration/src/server.rs b/integration/src/server.rs index 0301737..1b7e991 100644 --- a/integration/src/server.rs +++ b/integration/src/server.rs @@ -2,7 +2,7 @@ use crate::proto::{test_request, test_response, IntegrationService, TestRequest, use axum::extract::FromRequestParts; use axum::http::header::AUTHORIZATION; use axum::http::request::Parts; -use axum::{async_trait, Router}; +use axum::Router; use eyre::Result; use std::net::{Ipv4Addr, SocketAddrV4}; use std::pin::pin; @@ -135,7 +135,6 @@ pub async fn serve_grpc() -> Result { pub struct ExtractBearerToken(pub String); -#[async_trait] impl FromRequestParts for ExtractBearerToken where S: Send + Sync, diff --git a/server/Cargo.toml b/server/Cargo.toml index d1ee53a..7b0fe6b 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -4,17 +4,22 @@ description = "Twirp server related code" keywords = ["Twirp"] repository = "https://github.com/helsing-ai/twurst" documentation = "https://docs.rs/twurst-server" -version = "0.1.0" +version = "0.2.0" authors.workspace = true edition.workspace = true license.workspace = true rust-version.workspace = true [features] -grpc = ["dep:tonic", "dep:tokio-stream", "dep:pin-project-lite", "twurst-error/tonic-012"] +grpc = [ + "dep:tonic", + "dep:tokio-stream", + "dep:pin-project-lite", + "twurst-error/tonic-012", +] [dependencies] -twurst-error = { workspace = true, features = ["axum-07"] } +twurst-error = { workspace = true, features = ["axum-08"] } axum.workspace = true http-body-util.workspace = true pin-project-lite = { workspace = true, optional = true } diff --git a/server/src/codegen.rs b/server/src/codegen.rs index 5ec130e..79b981a 100644 --- a/server/src/codegen.rs +++ b/server/src/codegen.rs @@ -54,7 +54,7 @@ impl TwirpR >( mut self, path: &str, - call: impl (Fn(S, I, RequestParts, RS) -> F) + Clone + Send + 'static, + call: impl (Fn(S, I, RequestParts, RS) -> F) + Clone + Send + Sync + 'static, ) -> Self { let service = self.service.clone(); self.router = self.router.route( @@ -215,7 +215,7 @@ impl GrpcRouter { pub fn route< I: ReflectMessage + Default + 'static, O: ReflectMessage + 'static, - C: (Fn(S, I, RequestParts) -> F) + Clone + Send + 'static, + C: (Fn(S, I, RequestParts) -> F) + Clone + Send + Sync + 'static, F: Future> + Send + 'static, >( mut self, @@ -238,7 +238,7 @@ impl GrpcRouter { pub fn route_server_streaming< I: ReflectMessage + Default + 'static, O: ReflectMessage + 'static, - C: (Fn(S, I, RequestParts) -> F) + Clone + Send + 'static, + C: (Fn(S, I, RequestParts) -> F) + Clone + Send + Sync + 'static, F: Future> + Send + 'static, OS: Stream> + Send + 'static, >( @@ -262,7 +262,7 @@ impl GrpcRouter { pub fn route_client_streaming< I: ReflectMessage + Default + 'static, O: ReflectMessage + 'static, - C: (Fn(S, GrpcClientStream, RequestParts) -> F) + Clone + Send + 'static, + C: (Fn(S, GrpcClientStream, RequestParts) -> F) + Clone + Send + Sync + 'static, F: Future> + Send + 'static, >( mut self, @@ -285,7 +285,7 @@ impl GrpcRouter { pub fn route_streaming< I: ReflectMessage + Default + 'static, O: ReflectMessage + 'static, - C: (Fn(S, GrpcClientStream, RequestParts) -> F) + Clone + Send + 'static, + C: (Fn(S, GrpcClientStream, RequestParts) -> F) + Clone + Send + Sync + 'static, F: Future> + Send + 'static, OS: Stream> + Send + 'static, >(