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.
Hello Mickaël,
this adds various functions that I found useful while working with file-format.
To sum it up:
serde
support for the enumsFileFormat
andKind
.strum
, especially theIntoEnumIterator
andAsRef<str>
are useful when writing autogenerated code.from_extension
andfrom_media_type
. Both are returning a slice with the possible associated file formats for a media type or an extension. I also included the tests for all existing file formats as well as some health checks to ensure that all newly added file formats are also valid.I know it looks like a big pull request, but this is mostly caused by adding all the necessary tests and calling the macros for generating the
from_*
methods. The real code changes are only around 80 to 90 lines. (To be honest, if we accept thestrum
features, we can possibly drop all of the new tests forfrom_*
except three necessary, because we can useFileFormat::iter()
to write the tests.)Best regards
Felix