From ce87a3c21a37b9b6212bc20958cea2eb29381589 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 13 Dec 2024 09:24:59 +0100 Subject: [PATCH] util/bytes_request: Derive `Deref for BytesRequest` --- Cargo.toml | 2 +- src/util/bytes_request.rs | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1a57dbca1c5..ee714e15898 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,7 @@ chrono = { version = "=0.4.39", default-features = false, features = ["serde"] } clap = { version = "=4.5.23", features = ["derive", "env", "unicode", "wrap_help"] } cookie = { version = "=0.18.1", features = ["secure"] } deadpool-diesel = { version = "=0.6.1", features = ["postgres", "tracing"] } -derive_more = { version = "=1.0.0", features = ["deref"] } +derive_more = { version = "=1.0.0", features = ["deref", "deref_mut"] } dialoguer = "=0.11.0" diesel = { version = "=2.2.6", features = ["postgres", "serde_json", "chrono", "numeric"] } diesel-async = { version = "=0.5.2", features = ["async-connection-wrapper", "deadpool", "postgres"] } diff --git a/src/util/bytes_request.rs b/src/util/bytes_request.rs index 0cab3cdf99f..697bdfe7df9 100644 --- a/src/util/bytes_request.rs +++ b/src/util/bytes_request.rs @@ -3,28 +3,14 @@ use axum::body::Bytes; use axum::extract::{FromRequest, Request}; use axum::response::{IntoResponse, Response}; use axum::{async_trait, Extension, RequestExt}; +use derive_more::{Deref, DerefMut}; use http::StatusCode; use http_body_util::{BodyExt, LengthLimitError}; use std::error::Error; -use std::ops::{Deref, DerefMut}; -#[derive(Debug)] +#[derive(Debug, Deref, DerefMut)] pub struct BytesRequest(pub Request); -impl Deref for BytesRequest { - type Target = Request; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for BytesRequest { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - #[async_trait] impl FromRequest for BytesRequest where