Skip to content

Commit

Permalink
Derive some useful traits (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
orzogc authored Jun 24, 2021
1 parent 0cc30f1 commit 345d1d5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions pretend-isahc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use pretend::{Error, HeaderMap, Response, Result, Url};
use std::mem;

/// `ishac` based `pretend` client
#[derive(Clone, Debug)]
pub struct Client {
client: HttpClient,
}
Expand Down
2 changes: 1 addition & 1 deletion pretend-reqwest/src/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use reqwest::blocking::Client;
use std::mem;

/// `reqwest` based `pretend` blocking client
#[derive(Default)]
#[derive(Clone, Debug, Default)]
pub struct BlockingClient {
client: Client,
}
Expand Down
2 changes: 1 addition & 1 deletion pretend-reqwest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use reqwest::Client as RClient;
use std::mem;

/// `reqwest` based `pretend` client
#[derive(Default)]
#[derive(Clone, Debug, Default)]
pub struct Client {
client: RClient,
}
Expand Down
6 changes: 4 additions & 2 deletions pretend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ use crate::resolver::{InvalidUrlResolver, ResolveUrl, UrlResolver};
use serde::de::DeserializeOwned;

/// Response type
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Response<T> {
status: StatusCode,
headers: HeaderMap,
Expand Down Expand Up @@ -334,6 +335,7 @@ impl<T> Response<T> {
/// be implemented by this struct.
///
/// See crate level documentation for more information
#[derive(Clone, Debug)]
pub struct Pretend<C, R>
where
R: ResolveUrl,
Expand Down Expand Up @@ -393,7 +395,7 @@ impl<C> Pretend<C, InvalidUrlResolver> {
///
/// This wrapper type indicates that a method should return
/// a JSON-serialized body.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct Json<T>
where
T: DeserializeOwned,
Expand Down Expand Up @@ -428,7 +430,7 @@ where
/// When the HTTP request is successful, the `Ok` variant will
/// be returned, and when the HTTP request has failed, the
/// `Err` variant will be returned.
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub enum JsonResult<T, E>
where
T: DeserializeOwned,
Expand Down
2 changes: 2 additions & 0 deletions pretend/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub trait ResolveUrl {
/// Default URL resolver
///
/// This resolver appends the path to a base URL.
#[derive(Clone, Debug)]
pub struct UrlResolver {
base: Url,
}
Expand All @@ -48,6 +49,7 @@ impl ResolveUrl for UrlResolver {
///
/// `[Pretend::with_url]` or `[Pretend::with_url_resolver]` should be used to
/// set a valid URL resolver.
#[derive(Clone, Copy, Debug)]
pub struct InvalidUrlResolver;

impl ResolveUrl for InvalidUrlResolver {
Expand Down

0 comments on commit 345d1d5

Please sign in to comment.