pub fn new(response: &Response, accepted: Option<HashSet<StatusCode>>) -> Self {
        let code = response.status();

        if let Some(true) = accepted.map(|a| a.contains(&code)) {
            Self::Ok(code)
        } else {
            match response.error_for_status_ref() {
                Ok(_) if code.is_success() => Self::Ok(code),
                Ok(_) if code.is_redirection() => Self::Redirected(code),
                Ok(_) => Self::UnknownStatusCode(code),
                Err(e) => e.into(),
            }
        }
    }
/// Create a status object from a response and the set of accepted status codes
Create a status object from a response and the set of accepted status codes
Create a status object from a response and the set of accepted status codes
pub fn new(response: &Response, accepted: Option<HashSet<StatusCode>>) -> Self {
        let code = response.status();
        if let Some(true) = accepted.map(|a| a.contains(&code)) {
            Self::Ok(code)
        } else {
            match response.error_for_status_ref() {
                Ok(_) if code.is_success() => Self::Ok(code),
                Ok(_) if code.is_redirection() => Self::Redirected(code),
                Ok(_) => Self::UnknownStatusCode(code),
                Err(e) => e.into(),
            }
        }
    }
pub fn new ( response : & Response , accepted : Option < HashSet < StatusCode > > ) -> Self { let code = response . status ( ) ; if let Some ( true ) = accepted . map ( | a | a . contains ( & code ) ) { Self :: Ok ( code ) } else { match response . error_for_status_ref ( ) { Ok ( _ ) if code . is_success ( ) => Self :: Ok ( code ) , Ok ( _ ) if code . is_redirection ( ) => Self :: Redirected ( code ) , Ok ( _ ) => Self :: UnknownStatusCode ( code ) , Err ( e ) => e . into ( ) , } } }
Create a status object from a response and the set of accepted status codes
Create a status object from a response and the set of accepted status codes
response
&Response
accepted
Option<HashSet<StatusCode>>