Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What would be the smallest setting with tokio? #88

Closed
bamthomas opened this issue Sep 3, 2023 · 5 comments
Closed

What would be the smallest setting with tokio? #88

bamthomas opened this issue Sep 3, 2023 · 5 comments

Comments

@bamthomas
Copy link

bamthomas commented Sep 3, 2023

Thanks for the library. I'm using it with others for a load injector. I'm depending already on tokio.

I have this compilation error:

error[E0277]: the trait bound `tokio::net::TcpStream: futures_io::if_std::AsyncRead` is not satisfied
  --> src/imap_client.rs:6:13
   |
6  |     client: Client<TlsStream<TcpStream>>,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_io::if_std::AsyncRead` is not implemented for `tokio::net::TcpStream`

I have reproduced a similar compilation issue with the example: I removed optional features and set tokio as configured in my project (that includes same features from tokio i.e. rt-multi-thtread and macros). So I came with the following Cargo.toml:

[package]
name = "async-imap-examples"
version = "0.1.0"
publish = false
authors = ["dignifiedquire <me@dignifiedquire.com>"]
license = "Apache-2.0/MIT"
edition = "2018"


[dependencies]
anyhow = "1"
async-imap = { path = "../", features = [ "tokio" ]  }
async-native-tls = { version = "0.5", features = [ "tokio" ] }
futures = "0.3.28"
tokio = { version = "1.32", features = ["net", "io-util", "time", "rt", "rt-multi-thread", "macros"] }

And the headers from the idle file:

use std::env;
use std::time::Duration;

use anyhow::{bail, Result};
use async_imap::extensions::idle::IdleResponse::*;
use futures::StreamExt;

use tokio::{net::TcpStream, task, time::sleep};

#[tokio::main]
async fn main() -> Result<()> {
    // ...
}
// ...

What is missing or is misconfigured in this file?
(sorry if it's a dumb question, I'm not a rust advanced user yet)

@bamthomas bamthomas changed the title What would be the smalest setting with tokio? What would be the smallest setting with tokio? Sep 3, 2023
@link2xt
Copy link
Contributor

link2xt commented Sep 4, 2023

async-native-tls feature is named runtime-tokio, not tokio.

Should be like this:

async-native-tls = { version = "0.5", features = [ "runtime-tokio" ] }

@bamthomas
Copy link
Author

bamthomas commented Sep 4, 2023

thank you for your answer @link2xt but when I use runtime-tokio I have

error[E0252]: the name `AsyncReadExt` is defined multiple times                                                                                                                                                    
 --> /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/async-native-tls-0.5.0/src/runtime.rs:9:39                                                                                                           
  |                                                                                                                                                                                                                
6 | pub(crate) use futures_util::io::{AsyncReadExt, AsyncWriteExt};                                                                                                                                                
  |                                   ------------ previous import of the trait `AsyncReadExt` here                                                                                                                
...                                                                                                                                                                                                                
9 | pub(crate) use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite};                                                                                                                                               
  |                                       ^^^^^^^^^^^^ `AsyncReadExt` reimported here                                                                                                                              
  |                                                                                                                                                                                                                
  = note: `AsyncReadExt` must be defined only once in the type namespace of this module                                                                                                                            
help: you can use `as` to change the binding name of the import                                                                                                                                                    
  |                                                                                                                                                                                                                
9 | pub(crate) use tokio::io::{AsyncRead, AsyncReadExt as OtherAsyncReadExt, AsyncWrite};                      

Even if I use tokio 1.0.
Do I need to import async-native-tls in a specific way?

@link2xt
Copy link
Contributor

link2xt commented Sep 4, 2023

You also need to disable default runtime-async-std:

async-native-tls = { version = "0.5", default-features = false, features = ["runtime-tokio"] }

async-native-tls still enables async-std runtime by default for backwards compatibility.

@bamthomas
Copy link
Author

bamthomas commented Sep 4, 2023

Yay !!
It works. Thank you for your patience.

If this can help, I ended up with :

[dependencies]
anyhow = "1"
async-imap = { path = "../", default-features = false, features = [ "tokio", "runtime-tokio" ] }
async-native-tls = { version = "0.5", default-features = false, features = [ "runtime-tokio" ] }
futures = "0.3.28"
tokio = { version = "1.32", features = ["net", "io-util", "time", "rt", "rt-multi-thread", "macros"] }

@hpk42
Copy link
Contributor

hpk42 commented Sep 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants