Cleaning up some of the authenticator code
This commit is contained in:
parent
8d39bfd343
commit
43f4737b85
1 changed files with 43 additions and 38 deletions
|
|
@ -60,9 +60,17 @@ impl<T: Read+Write> Client<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Authenticate will authenticate with the server, using the authenticator given.
|
||||
pub fn authenticate<A: Authenticator>(&mut self, auth_type: &str, authenticator: A) -> Result<()> {
|
||||
match self.run_command(&format!("AUTHENTICATE {}", auth_type).to_string()) {
|
||||
Ok(_) => {
|
||||
Ok(_) => self.do_auth_handshake(authenticator),
|
||||
Err(e) => Err(e)
|
||||
}
|
||||
}
|
||||
|
||||
/// This func does the handshake process once the authenticate command is made.
|
||||
fn do_auth_handshake<A: Authenticator>(&mut self, authenticator: A) -> Result<()> {
|
||||
// TODO Clean up this code
|
||||
loop {
|
||||
let line = match self.readline() {
|
||||
Ok(l) => l,
|
||||
|
|
@ -99,9 +107,6 @@ impl<T: Read+Write> Client<T> {
|
|||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => Err(e)
|
||||
}
|
||||
}
|
||||
|
||||
/// Log in to the IMAP server.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue