Skip to content

Commit

Permalink
util/bytes_request: Derive Deref for BytesRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Dec 13, 2024
1 parent 5a968bc commit ce87a3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
18 changes: 2 additions & 16 deletions src/util/bytes_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bytes>);

impl Deref for BytesRequest {
type Target = Request<Bytes>;

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<S> FromRequest<S> for BytesRequest
where
Expand Down

0 comments on commit ce87a3c

Please sign in to comment.