AspectUnk / russh-sftp

SFTP subsystem supported server and client for Russh
Apache License 2.0
64 stars 21 forks source link

Implement easy conversion for open options #29

Closed girstenbrei closed 6 months ago

girstenbrei commented 6 months ago

Greets!

Implementing a small server which allows users to upload files to directories ( straightforward, no magic :grin: ) I found myself coding the translation between OpenFlags and tokio::fs::OpenOptions.

They pretty much match up, so I think implementing From between those types would be a nice usability enhancement. I noticed that russh-sftp does not have the tokio fs feature enabled (totally correct), so instead I went ahead implementing From<OpenFlags> for std::fs::OpenOptions, there is a From<std::fs::OpenOptions> for tokio::fs::OpenOptions in tokio.

I think this still keeps the nice usability, only an extra call to .into() without having to worry about implementation details. And it does not require any other change to russh-sftp.

The only downside I see would be targeting non-std environments, but I don't think this is a concern for russh-sftp?

Have a nice day! Christoph

AspectUnk commented 6 months ago

Thanks!