Skip to content

Commit

Permalink
Switch to tokio-0.2 final
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Dec 2, 2019
1 parent a260569 commit 2b8701b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 8 additions & 4 deletions tokio-imap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ azure-devops = { project = "dochtman/Projects", pipeline = "tokio-imap", build =
maintenance = { status = "passively-maintained" }

[dependencies]
bytes = "0.4"
futures = { version = "0.3.0-alpha.19", package = "futures-preview" }
bytes = "0.5"
futures = "0.3.1"
imap-proto = { version = "0.9.1", path = "../imap-proto" }
nom = "5"
tokio = "0.2.0-alpha.6"
tokio-rustls = "0.12.0-alpha.4"
tokio = { version = "0.2.2", features = ["tcp"] }
tokio-rustls = "0.12.0"
tokio-util = { version = "0.2.0", features = ["codec"] }
webpki-roots = "0.18.0"

[dev-dependencies]
tokio = { version = "0.2.2", features = ["macros", "tcp"] }
14 changes: 5 additions & 9 deletions tokio-imap/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@ use std::error::Error;
use std::fmt::{self, Display, Formatter};
use std::io;

use tokio::runtime::current_thread;

use tokio_imap::client::builder::{
CommandBuilder, FetchBuilderAttributes, FetchBuilderMessages, FetchBuilderModifiers,
};
use tokio_imap::proto::ResponseData;
use tokio_imap::types::{Attribute, AttributeValue, Response};
use tokio_imap::TlsClient;

fn main() {
#[tokio::main]
async fn main() {
let mut args = std::env::args();
let _ = args.next();
let server = args.next().expect("no server provided");
let login = args.next().expect("no login provided");
let password = args.next().expect("no password provided");
let mailbox = args.next().expect("no mailbox provided");

let mut rt = current_thread::Runtime::new().unwrap();
rt.block_on(async move {
if let Err(cause) = imap_fetch(&server, login, password, mailbox).await {
eprintln!("Fatal error: {}", cause);
}
});
if let Err(cause) = imap_fetch(&server, login, password, mailbox).await {
eprintln!("Fatal error: {}", cause);
}
}

async fn imap_fetch(
Expand Down
4 changes: 2 additions & 2 deletions tokio-imap/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::net::ToSocketAddrs;
use std::sync::Arc;

use futures::{SinkExt, StreamExt};
use tokio::codec::Decoder;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::tcp::TcpStream;
use tokio::net::TcpStream;
use tokio_rustls::rustls::ClientConfig;
use tokio_rustls::webpki::DNSNameRef;
use tokio_rustls::{client::TlsStream, TlsConnector};
use tokio_util::codec::Decoder;

use crate::proto::{ImapCodec, ImapTransport, ResponseData};
use imap_proto::builders::command::Command;
Expand Down
8 changes: 4 additions & 4 deletions tokio-imap/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::mem;

use bytes::{BufMut, Bytes, BytesMut};
use nom::{self, Needed};
use tokio::codec::{Decoder, Encoder, Framed};
use tokio_util::codec::{Decoder, Encoder, Framed};

use imap_proto;
use imap_proto::types::{Request, RequestId, Response};
Expand Down Expand Up @@ -62,9 +62,9 @@ impl Encoder for ImapCodec {
type Error = io::Error;
fn encode(&mut self, msg: Self::Item, dst: &mut BytesMut) -> Result<(), io::Error> {
dst.put(msg.0.as_bytes());
dst.put(b' ');
dst.put(&msg.1);
dst.put("\r\n");
dst.put_u8(b' ');
dst.put_slice(&msg.1);
dst.put("\r\n".as_bytes());
Ok(())
}
}
Expand Down

0 comments on commit 2b8701b

Please sign in to comment.