Skip to content

Commit ce87a3c

Browse files
committed
util/bytes_request: Derive Deref for BytesRequest
1 parent 5a968bc commit ce87a3c

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ chrono = { version = "=0.4.39", default-features = false, features = ["serde"] }
7171
clap = { version = "=4.5.23", features = ["derive", "env", "unicode", "wrap_help"] }
7272
cookie = { version = "=0.18.1", features = ["secure"] }
7373
deadpool-diesel = { version = "=0.6.1", features = ["postgres", "tracing"] }
74-
derive_more = { version = "=1.0.0", features = ["deref"] }
74+
derive_more = { version = "=1.0.0", features = ["deref", "deref_mut"] }
7575
dialoguer = "=0.11.0"
7676
diesel = { version = "=2.2.6", features = ["postgres", "serde_json", "chrono", "numeric"] }
7777
diesel-async = { version = "=0.5.2", features = ["async-connection-wrapper", "deadpool", "postgres"] }

src/util/bytes_request.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,14 @@ use axum::body::Bytes;
33
use axum::extract::{FromRequest, Request};
44
use axum::response::{IntoResponse, Response};
55
use axum::{async_trait, Extension, RequestExt};
6+
use derive_more::{Deref, DerefMut};
67
use http::StatusCode;
78
use http_body_util::{BodyExt, LengthLimitError};
89
use std::error::Error;
9-
use std::ops::{Deref, DerefMut};
1010

11-
#[derive(Debug)]
11+
#[derive(Debug, Deref, DerefMut)]
1212
pub struct BytesRequest(pub Request<Bytes>);
1313

14-
impl Deref for BytesRequest {
15-
type Target = Request<Bytes>;
16-
17-
fn deref(&self) -> &Self::Target {
18-
&self.0
19-
}
20-
}
21-
22-
impl DerefMut for BytesRequest {
23-
fn deref_mut(&mut self) -> &mut Self::Target {
24-
&mut self.0
25-
}
26-
}
27-
2814
#[async_trait]
2915
impl<S> FromRequest<S> for BytesRequest
3016
where

0 commit comments

Comments
 (0)