1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
use crate::requests::*;

#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
pub struct DetachedRequestType;

impl RequestType for DetachedRequestType {
    type Options = ();
    type Request = Result<HttpRequest, Error>;

    fn serialize(_options: Self::Options, request: &Self::Request) -> Result<HttpRequest, Error> {
        match request {
            &Ok(ref req) => Ok(req.clone()),
            &Err(ref err) => Err(ErrorKind::DetachedError(err.to_string()).into()),
        }
    }
}