The async example in README fails to compile, specifically the line:
let mut ftp_stream = ftp_stream.into_secure(AsyncNativeTlsConnector::from(TlsConnector::new()), "test.rebex.net").await.unwrap();
Error message:
error[E0271]: type mismatch resolving `<AsyncNativeTlsConnector as AsyncTlsConnector>::Stream == AsyncNoTlsStream`
--> test/src/main.rs:8:49
|
8 | ...am.into_secure(AsyncNativeTlsConnector::from(TlsConnector::new()), "...
| ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `AsyncNoTlsStream`, found `AsyncNativeTlsStream`
| |
| required by a bound introduced by this call
|
note: required by a bound in `ImplAsyncFtpStream::<T>::into_secure`
--> /home/michaelyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/suppaftp-5.1.2/src/async_ftp/mod.rs:122:47
|
122 | ... AsyncTlsConnector<Stream = T> + 'static,
| ^^^^^^^^^^ required by this bound in `ImplAsyncFtpStream::<T>::into_secure`
Investigation
I did some digging around in the source file, and it appears that the problem stems from the fact that ImplAsyncFtpStream::into_secure requires the bound on T for the parameter tls_connector:
which suggests that the stream before and after switching to secure mode must be the same, and hence why AsyncFtpStream with T = AsyncNoTlsStream failed to be promoted to a secure ftp stream with T = AsyncNativeTlsStream.
On the other hand, the into_secure documentation provides the correct example:
let mut ctx = TlsConnector::new();
let mut ftp_stream = ImplAsyncFtpStream::connect("127.0.0.1:21").await.unwrap();
let mut ftp_stream = ftp_stream.into_secure(ctx, "localhost").await.unwrap();
Where the original ftp_stream has an indeterminate generic type T that is subsequently inferred in the following line.
Hence, which of the two (either promotion from insecure stream or direct construction from ImplAsyncFtpStream) examples is the desired behaviour?
That code compiles in unit tests, so it must be correct. Probably your stream is not of the type AsyncNativeTlsFtpStream, but probably is a AsyncFtpStream.
Description
The async example in README fails to compile, specifically the line:
Error message:
Investigation
I did some digging around in the source file, and it appears that the problem stems from the fact that
ImplAsyncFtpStream::into_secure
requires the bound onT
for the parametertls_connector
:which suggests that the stream before and after switching to secure mode must be the same, and hence why
AsyncFtpStream
withT = AsyncNoTlsStream
failed to be promoted to a secure ftp stream withT = AsyncNativeTlsStream
.On the other hand, the
into_secure
documentation provides the correct example:Where the original
ftp_stream
has an indeterminate generic typeT
that is subsequently inferred in the following line.Hence, which of the two (either promotion from insecure stream or direct construction from
ImplAsyncFtpStream
) examples is the desired behaviour?Environment