diff --git a/CHANGELOG.md b/CHANGELOG.md index ce83279..0e600dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog - [Changelog](#changelog) + - [6.0.3](#603) - [6.0.2](#602) - [6.0.1](#601) - [6.0.0](#600) @@ -35,6 +36,13 @@ --- +## 6.0.3 + +Released on 15/10/2024 + +- Added `Send` marker to the Closure: `dyn Fn(SocketAddr) -> Pin> + Send>> + Send;` +- Added unit test to guarantee that FtpStream stays `Send` + ## 6.0.2 Released on 14/10/2024 diff --git a/Cargo.toml b/Cargo.toml index 54739b6..b0fd2fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["suppaftp", "suppaftp-cli"] resolver = "2" [workspace.package] -version = "6.0.2" +version = "6.0.3" edition = "2021" authors = [ "Christian Visintin ", diff --git a/README.md b/README.md index ec8b883..940e93b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

Developed by veeso and Matt McCoy

-

Current version: 6.0.2 (14/10/2024)

+

Current version: 6.0.3 (15/10/2024)

Pin> + Send>>; + dyn Fn(SocketAddr) -> Pin> + Send>> + Send; /// Stream to interface with the FTP server. This interface is only for the command stream. pub struct ImplAsyncFtpStream @@ -257,7 +257,9 @@ where /// to create the [`TcpStream`] for the data connection in passive mode. pub fn passive_stream_builder(mut self, stream_builder: F) -> Self where - F: Fn(SocketAddr) -> Pin> + Send>> + 'static, + F: Fn(SocketAddr) -> Pin> + Send>> + + Send + + 'static, { self.passive_stream_builder = Box::new(stream_builder); self @@ -1447,6 +1449,27 @@ mod test { }); } + /// Test if the stream is Send + fn is_send(_send: T) {} + + #[async_attributes::test] + async fn test_ftp_stream_should_be_send() { + crate::log_init(); + let ftp_stream = AsyncFtpStream::connect("test.rebex.net:21") + .await + .unwrap() + .passive_stream_builder(|addr| { + Box::pin(async move { + println!("Connecting to {}", addr); + TcpStream::connect(addr) + .await + .map_err(FtpError::ConnectionError) + }) + }); + + is_send::(ftp_stream); + } + // -- test utils #[cfg(feature = "with-containers")] diff --git a/suppaftp/src/sync_ftp/mod.rs b/suppaftp/src/sync_ftp/mod.rs index e5ba5fb..9824e9e 100644 --- a/suppaftp/src/sync_ftp/mod.rs +++ b/suppaftp/src/sync_ftp/mod.rs @@ -1497,4 +1497,20 @@ mod test { TcpStream::connect(addr).map_err(FtpError::ConnectionError) }); } + + /// Test if the stream is Send + fn is_send(_send: T) {} + + #[test] + fn test_ftp_stream_should_be_send() { + crate::log_init(); + let ftp_stream = FtpStream::connect("test.rebex.net:21") + .unwrap() + .passive_stream_builder(|addr| { + println!("Connecting to {}", addr); + TcpStream::connect(addr).map_err(FtpError::ConnectionError) + }); + + is_send::(ftp_stream); + } }