rust-ftp
rust-ftp copied to clipboard
QUIT on drop
Now the user should issue QUIT
manually and I think that should be automated. I suggest implement Drop
trait and issue quit
on drop and probably make the function private.
I think this would be a great improvement, but why make the quit
function private? It may be a good idea to leave it around if a user wants to manually quit.
If we leave it public then we should track if the user issued it already and that is one more field in FtpStream struct. But that is not really a big deal.
+1 to have imp Drop for FtpStream do the QUIT. However, this is a breaking change, so if we take this road there might be other breaking changes that may be worth doing. For instance I see that the return type of simple_retr is Result<Cursor<Vec
To add to this (perhaps a bit late), the purpose of making the quit
function private is two-fold:
- It's consistent with other rust types in the standard library. Note the lack of a
close()
function on sockets or files. - It prevents the user from calling
quit
multiple times by accident. Let the compiler handle the cleanup. The borrow checker can handle this for you.
One last option would be to decorate quit()
with a:
#[deprecated(
since = "4.0.0",
note = "This function is now a no-op. quit is implicitly called on drop"
)]
pub fn quit(&mut self) {}
and move the actual implementation to Drop
. This would warn the users, but keep probably 90% of the existing code working.