veeso / suppaftp

a super FTP/FTPS client library for Rust with support for both passive and active mode
Apache License 2.0
121 stars 31 forks source link

[BUG] - expected `AsyncNoTlsStream`, found `AsyncNativeTlsStream` #52

Closed brunoarueira closed 1 year ago

brunoarueira commented 1 year ago

Description

On a pet project I'm working on, I've set to use async-native-tls feature and when I use into_secure with AsyncNativeTlsConnector::from(TlsConnector::new()), similar to the README, I got the error from title of this bug.

Steps to reproduce

Steps to reproduce the bug you encountered:

use std::error::Error;
use suppaftp::{AsyncFtpStream, AsyncNativeTlsConnector};
use suppaftp::async_native_tls::{TlsConnector, TlsStream};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    // Create a connection to an FTP server and authenticate to it.
    let mut ftp_stream = AsyncFtpStream::connect("localhost:21").await.unwrap();

    let mut connector = TlsConnector::new();

    let mut ftp_stream =
        ftp_stream
        .into_secure(AsyncNativeTlsConnector::from(connector), "localhost")
        .await
        .unwrap();

    Ok(())
}

Probably the bug is about this:

https://github.com/veeso/suppaftp/blob/5bf40b4bc68658180bdfe7c54cae5d9869c64ae6/suppaftp/src/lib.rs#L183

Missing to generate a type for async-native-tls feature.

Expected behaviour

Using the above code must work as expected and should compile at least.

Environment

Additional information

None

brunoarueira commented 1 year ago

After digging a little bit, I've found the correct way to do the connection using async-native-tls, we should use the following type:

https://github.com/veeso/suppaftp/blob/5bf40b4bc68658180bdfe7c54cae5d9869c64ae6/suppaftp/src/lib.rs#L192

So, probably I'll send a pr to fix the docs 😄