fs-err icon indicating copy to clipboard operation
fs-err copied to clipboard

Missing structs

Open Emerentius opened this issue 5 years ago • 2 comments

There exist several structs in std::fs which don't appear in fs_err

  • DirBuilder
  • Metadata
  • FileType
  • Permissions

Of these, the first 2 have methods returning io::Result<_> which would benefit from wrappers. The last 2 don't have any fallible methods. If fs-err re-exported them, it would add to the "drop-in" quality of the crate. The downside is that if std ever adds fallible methods later, they'd need to be replaced with wrappers in a breaking change.

In the case of Metadata, there already are several APIs which return std::fs::Metadata. When Metadata is wrapped, these should be switched to return the wrapper (breaking change).

Emerentius avatar Sep 19 '20 12:09 Emerentius

Thinking about it, the re-exports don't add any new forwards-compatibility issues, at least so long as one wants to keep the API consistent and without any surprises.

If FileType were wrapped, then fs_err::DirEntry::file_type would also need to be changed. That's already a breaking change. Similarly for Permissions, there are two set_permissions functions which take a Permissions struct which would need to be changed.

Emerentius avatar Sep 26 '20 19:09 Emerentius

DirBuilder would certainly make sense to wrap, especially since we already provider a wrapper for tokio::fs::DirBuilder.

It looks like the fallible methods on Metadata only fail if the platform doesn't support the operation - so arguably the path isn't relevant anyway. I dont think its worth a breaking change to wrap it, but I think a re-export is a good idea (and likewise for Permissions and FileType)

andrewhickman avatar Nov 20 '23 13:11 andrewhickman