Repository: dani-garcia/rust_async_ftp (language: rust)

Issue:
FtpStream::retr should allow a more generic error type
[FtpStream::retr](https://docs.rs/async_ftp/4.0.2/async_ftp/struct.FtpStream.html#method.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.


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

Fix patch:
diff --git a/src/ftp.rs b/src/ftp.rs
index 35123c3..dfc4b79 100644
--- a/src/ftp.rs
+++ b/src/ftp.rs
@@ -337,10 +337,11 @@ impl FtpStream {
     ///   assert!(conn.rm("retr.txt").await.is_ok());
     /// };
     /// ```
-    pub async fn retr<F, T, P>(&mut self, filename: &str, reader: F) -> Result<T>
+    pub async fn retr<F, T, P, E>(&mut self, filename: &str, reader: F) -> std::result::Result<T, E>
     where
         F: Fn(BufReader<DataStream>) -> P,
-        P: std::future::Future<Output = Result<T>>,
+        P: std::future::Future<Output = std::result::Result<T, E>>,
+        E: From<FtpError>,
     {
         let retr_command = format!("RETR {}\r\n", filename);
 


Test patch: