async-email / async-smtp

Apache License 2.0
59 stars 12 forks source link

async-std `TcpStream` impls `BufRead` w/ `AsyncWrite` #63

Open pinkforest opened 1 month ago

pinkforest commented 1 month ago

https://github.com/async-email/async-smtp/commit/eed4f0bfcc12e5cb5672073fbd83d56f3b81eec5

So wrapping TcpStream with BufReader should work ?

Even if I wrap it to BufReader then it wants AsyncWrite too complicating setting stuff like async-native-tls up ?

I could implement my own type with those implemented but probably doc neeeds to be adjusted - it's not as straightforward now in combination with the types it's usually used as the doc points to direct use with TcpStream.

45 |                 let mut transport = SmtpTransport::new(client, reader).await?;                
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsyncWrite` is not implemented for `std::io::BufReader<TlsStream<async_std::net::TcpStream>>`

Repro: https://github.com/pinkforest/repro-async-std-async-smtp

For now I'm just using 0.8 as but got to refactor and port this stuff over off async-std probably

link2xt commented 1 month ago

Delta Chat uses tokio, but implements a wrapper type there because it also needs to progagate read timeouts over TLS and SOCKS5: https://github.com/deltachat/deltachat-core-rust/blob/a198e9fce84deb777c712a41d370ab8cf11cc240/src/net/session.rs