diff options
| author | Fuwn <[email protected]> | 2026-04-14 09:01:04 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-04-14 09:01:04 +0000 |
| commit | a48462a29ce0a3adbf0c132c28c61194f60d99b0 (patch) | |
| tree | 3d7cda0368c2be310fb9a5bc2661ae7c9daf9c99 /src/handler | |
| parent | chore(license): Relicense under MIT OR Apache-2.0 (diff) | |
| download | archived-windmark-a48462a29ce0a3adbf0c132c28c61194f60d99b0.tar.xz archived-windmark-a48462a29ce0a3adbf0c132c28c61194f60d99b0.zip | |
perf(router)!: Remove AsyncMutex from route and error handlers
Diffstat (limited to 'src/handler')
| -rw-r--r-- | src/handler/response/error.rs | 6 | ||||
| -rw-r--r-- | src/handler/response/route.rs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/handler/response/error.rs b/src/handler/response/error.rs index 6d6df34..8303f25 100644 --- a/src/handler/response/error.rs +++ b/src/handler/response/error.rs @@ -5,16 +5,16 @@ use crate::{context::ErrorContext, response::Response}; #[allow(clippy::module_name_repetitions)] #[async_trait] pub trait ErrorResponse: Send + Sync { - async fn call(&mut self, context: ErrorContext) -> Response; + async fn call(&self, context: ErrorContext) -> Response; } #[async_trait] impl<T, F> ErrorResponse for T where - T: FnMut(ErrorContext) -> F + Send + Sync, + T: Fn(ErrorContext) -> F + Send + Sync, F: std::future::Future<Output = Response> + Send + 'static, { - async fn call(&mut self, context: ErrorContext) -> Response { + async fn call(&self, context: ErrorContext) -> Response { (*self)(context).await } } diff --git a/src/handler/response/route.rs b/src/handler/response/route.rs index d6977a9..b71e76d 100644 --- a/src/handler/response/route.rs +++ b/src/handler/response/route.rs @@ -5,16 +5,16 @@ use crate::{context::RouteContext, response::Response}; #[allow(clippy::module_name_repetitions)] #[async_trait] pub trait RouteResponse: Send + Sync { - async fn call(&mut self, context: RouteContext) -> Response; + async fn call(&self, context: RouteContext) -> Response; } #[async_trait] impl<T, F> RouteResponse for T where - T: FnMut(RouteContext) -> F + Send + Sync, + T: Fn(RouteContext) -> F + Send + Sync, F: std::future::Future<Output = Response> + Send + 'static, { - async fn call(&mut self, context: RouteContext) -> Response { + async fn call(&self, context: RouteContext) -> Response { (*self)(context).await } } |