Skip to content

Commit

Permalink
tests/util/response: Derive Deref for Response
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Dec 13, 2024
1 parent a4067c4 commit 5a968bc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/tests/util/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@ use bytes::Bytes;
use googletest::prelude::*;
use serde_json::Value;
use std::marker::PhantomData;
use std::ops::Deref;
use std::str::from_utf8;

use crate::rate_limiter::LimitedAction;
use derive_more::Deref;
use http::{header, StatusCode};

/// A type providing helper methods for working with responses
#[derive(Deref)]
#[must_use]
pub struct Response<T> {
#[deref]
response: hyper::Response<Bytes>,
return_type: PhantomData<T>,
}

impl Deref for Response<()> {
type Target = hyper::Response<Bytes>;

fn deref(&self) -> &Self::Target {
&self.response
}
}

impl<T> Response<T>
where
for<'de> T: serde::Deserialize<'de>,
Expand Down

0 comments on commit 5a968bc

Please sign in to comment.