diff --git a/Cargo.toml b/Cargo.toml index 6d1de82..9211990 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,9 +18,8 @@ serde = ["dep:serde", "dep:serde_json"] auto-vary = ["futures", "tokio", "tower"] [dependencies] -axum-core = "0.4" +axum-core = "0.5" http = { version = "1", default-features = false } -async-trait = "0.1" # Optional dependencies required for the `guards` feature. tower = { version = "0.5", default-features = false, optional = true } @@ -36,8 +35,8 @@ tokio = { version = "1", features = ["sync"], optional = true } futures = { version = "0.3", default-features = false, optional = true } [dev-dependencies] -axum = { version = "0.7", default-features = false } -axum-test = "16" +axum = { version = "0.8", default-features = false} +axum-test = "17" tokio = { version = "1", features = ["full"] } tokio-test = "0.4" diff --git a/src/auto_vary.rs b/src/auto_vary.rs index cf861a2..25243ff 100644 --- a/src/auto_vary.rs +++ b/src/auto_vary.rs @@ -45,7 +45,7 @@ pub(crate) trait Notifier { fn sender(&mut self) -> Option>; fn notify(&mut self) { - if let Some(sender) = self.sender().take() { + if let Some(sender) = self.sender() { sender.send(()).ok(); } } diff --git a/src/extractors.rs b/src/extractors.rs index 5f25683..1a9e134 100644 --- a/src/extractors.rs +++ b/src/extractors.rs @@ -1,6 +1,5 @@ //! Axum extractors for htmx request headers. -use async_trait::async_trait; use axum_core::extract::FromRequestParts; use http::request::Parts; @@ -21,7 +20,6 @@ use crate::{ #[derive(Debug, Clone, Copy)] pub struct HxBoosted(pub bool); -#[async_trait] impl FromRequestParts for HxBoosted where S: Send + Sync, @@ -30,9 +28,9 @@ where async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { if parts.headers.contains_key(HX_BOOSTED) { - return Ok(HxBoosted(true)); + Ok(HxBoosted(true)) } else { - return Ok(HxBoosted(false)); + Ok(HxBoosted(false)) } } } @@ -47,7 +45,6 @@ where #[derive(Debug, Clone)] pub struct HxCurrentUrl(pub Option); -#[async_trait] impl FromRequestParts for HxCurrentUrl where S: Send + Sync, @@ -64,7 +61,7 @@ where return Ok(HxCurrentUrl(url)); } - return Ok(HxCurrentUrl(None)); + Ok(HxCurrentUrl(None)) } } @@ -75,7 +72,6 @@ where #[derive(Debug, Clone, Copy)] pub struct HxHistoryRestoreRequest(pub bool); -#[async_trait] impl FromRequestParts for HxHistoryRestoreRequest where S: Send + Sync, @@ -84,9 +80,9 @@ where async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { if parts.headers.contains_key(HX_HISTORY_RESTORE_REQUEST) { - return Ok(HxHistoryRestoreRequest(true)); + Ok(HxHistoryRestoreRequest(true)) } else { - return Ok(HxHistoryRestoreRequest(false)); + Ok(HxHistoryRestoreRequest(false)) } } } @@ -101,7 +97,6 @@ where #[derive(Debug, Clone)] pub struct HxPrompt(pub Option); -#[async_trait] impl FromRequestParts for HxPrompt where S: Send + Sync, @@ -115,7 +110,7 @@ where } } - return Ok(HxPrompt(None)); + Ok(HxPrompt(None)) } } @@ -129,7 +124,6 @@ where #[derive(Debug, Clone, Copy)] pub struct HxRequest(pub bool); -#[async_trait] impl FromRequestParts for HxRequest where S: Send + Sync, @@ -144,9 +138,9 @@ where .map(crate::auto_vary::Notifier::notify); if parts.headers.contains_key(HX_REQUEST) { - return Ok(HxRequest(true)); + Ok(HxRequest(true)) } else { - return Ok(HxRequest(false)); + Ok(HxRequest(false)) } } } @@ -162,7 +156,6 @@ where #[derive(Debug, Clone)] pub struct HxTarget(pub Option); -#[async_trait] impl FromRequestParts for HxTarget where S: Send + Sync, @@ -182,7 +175,7 @@ where } } - return Ok(HxTarget(None)); + Ok(HxTarget(None)) } } @@ -197,7 +190,6 @@ where #[derive(Debug, Clone)] pub struct HxTriggerName(pub Option); -#[async_trait] impl FromRequestParts for HxTriggerName where S: Send + Sync, @@ -217,7 +209,7 @@ where } } - return Ok(HxTriggerName(None)); + Ok(HxTriggerName(None)) } } @@ -232,7 +224,6 @@ where #[derive(Debug, Clone)] pub struct HxTrigger(pub Option); -#[async_trait] impl FromRequestParts for HxTrigger where S: Send + Sync, @@ -252,6 +243,6 @@ where } } - return Ok(HxTrigger(None)); + Ok(HxTrigger(None)) } }