From abad1f41712b5dced9ebbd11fae5abec50058392 Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Wed, 29 Aug 2018 16:08:53 +0200 Subject: [PATCH] adjust examples to the latest changes --- examples/basic.rs | 13 ++++++------- examples/gmail_oauth2.rs | 11 +++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/basic.rs b/examples/basic.rs index fc643a3..df74eb9 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,7 +1,6 @@ extern crate imap; extern crate native_tls; -use imap::client::UnauthenticatedClient; use native_tls::TlsConnector; // To connect to the gmail IMAP server with this you will need to allow unsecure apps access. @@ -12,9 +11,9 @@ fn main() { let port = 993; let socket_addr = (domain, port); let ssl_connector = TlsConnector::builder().build().unwrap(); - let unauth_client = UnauthenticatedClient::secure_connect(socket_addr, domain, &ssl_connector).unwrap(); + let client = imap::client::secure_connect(socket_addr, domain, &ssl_connector).unwrap(); - let mut imap_socket = match unauth_client.login("username", "password") { + let mut imap_session = match client.login("username", "password") { Ok(c) => c, Err((e, _unauth_client)) => { println!("failed to login: {}", e); @@ -22,26 +21,26 @@ fn main() { }, }; - match imap_socket.capabilities() { + match imap_session.capabilities() { Ok(capabilities) => for capability in capabilities.iter() { println!("{}", capability); }, Err(e) => println!("Error parsing capability: {}", e), }; - match imap_socket.select("INBOX") { + match imap_session.select("INBOX") { Ok(mailbox) => { println!("{}", mailbox); } Err(e) => println!("Error selecting INBOX: {}", e), }; - match imap_socket.fetch("2", "body[text]") { + match imap_session.fetch("2", "body[text]") { Ok(msgs) => for msg in &msgs { print!("{:?}", msg); }, Err(e) => println!("Error Fetching email 2: {}", e), }; - imap_socket.logout().unwrap(); + imap_session.logout().unwrap(); } diff --git a/examples/gmail_oauth2.rs b/examples/gmail_oauth2.rs index d334cf7..051c7e2 100644 --- a/examples/gmail_oauth2.rs +++ b/examples/gmail_oauth2.rs @@ -4,7 +4,6 @@ extern crate native_tls; use base64::encode; use imap::authenticator::Authenticator; -use imap::client::UnauthenticatedClient; use native_tls::TlsConnector; struct GmailOAuth2 { @@ -33,9 +32,9 @@ fn main() { let port = 993; let socket_addr = (domain, port); let ssl_connector = TlsConnector::builder().build().unwrap(); - let unauth_client = UnauthenticatedClient::secure_connect(socket_addr, domain, &ssl_connector).unwrap(); + let client = imap::client::secure_connect(socket_addr, domain, &ssl_connector).unwrap(); - let mut imap_socket = match unauth_client.authenticate("XOAUTH2", gmail_auth) { + let mut imap_session = match client.authenticate("XOAUTH2", gmail_auth) { Ok(c) => c, Err((e, _unauth_client)) => { println!("error authenticating: {}", e); @@ -43,17 +42,17 @@ fn main() { } }; - match imap_socket.select("INBOX") { + match imap_session.select("INBOX") { Ok(mailbox) => println!("{}", mailbox), Err(e) => println!("Error selecting INBOX: {}", e), }; - match imap_socket.fetch("2", "body[text]") { + match imap_session.fetch("2", "body[text]") { Ok(msgs) => for msg in &msgs { print!("{:?}", msg); }, Err(e) => println!("Error Fetching email 2: {}", e), }; - imap_socket.logout().unwrap(); + imap_session.logout().unwrap(); }