dani-garcia / rust_async_ftp

Fork of https://crates.io/crates/ftp with tokio async support
Apache License 2.0
21 stars 14 forks source link

FtpStream::retr should allow a more generic error type #5

Closed dodomorandi closed 4 years ago

dodomorandi commented 4 years ago

FtpStream::retr is very useful, because it allows parsing streaming data from the server and, at the same time, it automatically handles FTP response statuses.

However, there is a major issue related to the error type of the inner function: if you need to perform non-trivial parsing of the remote data, you will end up with a richer set of errors, making FtpStream::retr unusable because FtpError cannot encapsulate all the possible errors anymore.

I propose to change the return type from Result<T, FtpError> to Result<T, E> where E: From<FtpError>. If you like the idea, I will be glad to send you a PR.

dani-garcia commented 4 years ago

I'd have to see how this changes the API, but I like the idea, yeah