Simplify metadata/file-type handling in filesystem::primitives - #14356
Open
alexcrichton wants to merge 1 commit into
Open
alexcrichton wants to merge 1 commit into
alexcrichton wants to merge 1 commit into
Conversation
Avoid unwrapping structures into a shape only to re-wrap them later on into a WASI-defined shape. Instead remove various extension traits and shuffling of fields and instead use an `enum` for the definitions of `Metadata` and `FileType` which are either standard library types or rustix-based types. Accessors then delegate to the appropriate fields depending on how the data lies at rest. The goal here is to remove layer of cognitive indirection where there's a platform-specific source of truth for the underlying data. Accessors where a specific type is requested or a particular operation is where the interpretation of the underlying data happens then. Note that the reason that `std::fs::Metadata` alone isn't sufficient is that the Rust standard library doesn't bind functions like `statat` and there's no way to create a `std::fs::Metadata` externally from the standard library, hence the Unix-specific layer where metadata might be `std::fs::Metadata` and might be `rustix::fs::Stat`.
alexcrichton
force-pushed
the
refactor-metadata
branch
from
September 18, 2026 22:27
0f8b8c4 to
13e29f8
Compare
alexcrichton
marked this pull request as ready for review
September 18, 2026 22:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid unwrapping structures into a shape only to re-wrap them later on into a WASI-defined shape. Instead remove various extension traits and shuffling of fields and instead use an
enumfor the definitions ofMetadataandFileTypewhich are either standard library types or rustix-based types. Accessors then delegate to the appropriate fields depending on how the data lies at rest.The goal here is to remove layer of cognitive indirection where there's a platform-specific source of truth for the underlying data. Accessors where a specific type is requested or a particular operation is where the interpretation of the underlying data happens then.
Note that the reason that
std::fs::Metadataalone isn't sufficient is that the Rust standard library doesn't bind functions likestatatand there's no way to create astd::fs::Metadataexternally from the standard library, hence the Unix-specific layer where metadata might bestd::fs::Metadataand might berustix::fs::Stat.