-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ergonomics for external image formats #2368
Comments
Maybe the hooks could even have a global registry. Otherwise you still need to coordinate with all the deps using the |
What if the |
Including all the format selection logic into I'm not too worried about file extensions, but if we went this direction we'd need to improve our magic byte format sniffing. For instance, at the moment we assume that any file that starts with RIFF is WebP, even though there's a bunch of other file formats that also use RIFF containers... Having a global format registry could work, though it would require some trickery to handle the generics. Our built-in codecs are monomorphized for each reader type. But for external formats the registry would have to deal with only a single kind of reader. We'd probably have to operate on |
A custom wrapper sounds fine, it just introduces one additional requirement to me: We should be able to change the interface for hooks to update those bounds, in a compatible release. There's two reasons, first I don't want a repeat of when we added the Note: https://docs.rs/flexible-io/latest/flexible_io/ I've been churning on this a bit low-key in the background, since the issue of optional traits and combining different io traits has been .. contentious. I realize it's unsafe, but motivating |
Created #2372 to try out a global hooks design. I'm not quite sure how something like |
At the moment, it is pretty difficult to work with formats that aren't implemented directly in this crate. Other crates largely haven't chosen to implement our
ImageDecoder
trait, and even if they did, there isn't a way to use them when working withImageReader
or our file format detection logic. This has created a lot of pressure for us to expand the list of supported formats.The question is whether we could add some form of hooks support so that downstream users could inject their own format decoders to use in addition to the built-in ones. It is a bit messy, but perhaps something like this could work:
The text was updated successfully, but these errors were encountered: