pub fn from_response(response: &Response) -> Result<ServerInfo, Error> {
        let name = match response.first_word() {
            Some(name) => name,
            None => return Err(Error::ResponseParsing("Could not read server name")),
        };

        let mut features: HashSet<Extension> = HashSet::new();

        for line in response.message.as_slice() {
            if line.is_empty() {
                continue;
            }

            let split: Vec<&str> = line.split_whitespace().collect();
            match split[0] {
                "8BITMIME" => {
                    features.insert(Extension::EightBitMime);
                }
                "SMTPUTF8" => {
                    features.insert(Extension::SmtpUtfEight);
                }
                "STARTTLS" => {
                    features.insert(Extension::StartTls);
                }
                "AUTH" => {
                    for &mechanism in &split[1..] {
                        match mechanism {
                            "PLAIN" => {
                                features.insert(Extension::Authentication(Mechanism::Plain));
                            }
                            "LOGIN" => {
                                features.insert(Extension::Authentication(Mechanism::Login));
                            }
                            "XOAUTH2" => {
                                features.insert(Extension::Authentication(Mechanism::Xoauth2));
                            }
                            _ => (),
                        }
                    }
                }
                _ => (),
            };
        }

        Ok(ServerInfo {
            name: name.to_string(),
            features,
        })
    }
/// Parses a EHLO response to create a `ServerInfo`
Parses a EHLO response to create a `ServerInfo`
Parses a EHLO response to create a ` ServerInfo `
pub fn from_response(response: &Response) -> Result<ServerInfo, Error> {
        let name = match response.first_word() {
            Some(name) => name,
            None => return Err(Error::ResponseParsing("Could not read server name")),
        };
        let mut features: HashSet<Extension> = HashSet::new();
        for line in response.message.as_slice() {
            if line.is_empty() {
                continue;
            }
            let split: Vec<&str> = line.split_whitespace().collect();
            match split[0] {
                "8BITMIME" => {
                    features.insert(Extension::EightBitMime);
                }
                "SMTPUTF8" => {
                    features.insert(Extension::SmtpUtfEight);
                }
                "STARTTLS" => {
                    features.insert(Extension::StartTls);
                }
                "AUTH" => {
                    for &mechanism in &split[1..] {
                        match mechanism {
                            "PLAIN" => {
                                features.insert(Extension::Authentication(Mechanism::Plain));
                            }
                            "LOGIN" => {
                                features.insert(Extension::Authentication(Mechanism::Login));
                            }
                            "XOAUTH2" => {
                                features.insert(Extension::Authentication(Mechanism::Xoauth2));
                            }
                            _ => (),
                        }
                    }
                }
                _ => (),
            };
        }
        Ok(ServerInfo {
            name: name.to_string(),
            features,
        })
    }
pub fn from_response ( response : & Response ) -> Result < ServerInfo , Error > { let name = match response . first_word ( ) { Some ( name ) => name , None => return Err ( Error :: ResponseParsing ( " " ) ) , } ; let mut features : HashSet < Extension > = HashSet :: new ( ) ; for line in response . message . as_slice ( ) { if line . is_empty ( ) { continue ; } let split : Vec < & str > = line . split_whitespace ( ) . collect ( ) ; match split [ 0 ] { " " => { features . insert ( Extension :: EightBitMime ) ; } " " => { features . insert ( Extension :: SmtpUtfEight ) ; } " " => { features . insert ( Extension :: StartTls ) ; } " " => { for & mechanism in & split [ 1 .. ] { match mechanism { " " => { features . insert ( Extension :: Authentication ( Mechanism :: Plain ) ) ; } " " => { features . insert ( Extension :: Authentication ( Mechanism :: Login ) ) ; } " " => { features . insert ( Extension :: Authentication ( Mechanism :: Xoauth2 ) ) ; } _ => ( ) , } } } _ => ( ) , } ; } Ok ( ServerInfo { name : name . to_string ( ) , features , } ) }
Parses a EHLO response to create a `ServerInfo`
Parses a EHLO response to create a ` ServerInfo `
response
&Response
response
&Response