felixc / rexiv2

Rust library for read/write access to media-file metadata (Exif, XMP, and IPTC)
GNU General Public License v3.0
79 stars 17 forks source link

Should get_media_type() return an enum of possible values, instead of a String? #24

Closed felixc closed 8 years ago

felixc commented 8 years ago

The list of supported image types in exiv2 is finite, and the source can be inspected to find what media type (slightly inaccurately called "mime type") they describe themselves as (for example, here's the code for GIFs).

Currently we follow Exiv2 and GExiv2's lead and just return a string.

However, is it likely that users want to know the media type in order to compare it against some known ones, and would an enum therefore be more useful?

In case the reported media type is not recognized, the MediaType enum could contain a fallback variant like "Unknown(String)" that provides the underlying raw string. Or perhaps all variants should expose their string representation too?