-
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
Deprecate compound input fn in favor of Reader #1327
base: main
Are you sure you want to change the base?
Deprecate compound input fn in favor of Reader #1327
Conversation
I'm very much in favor of deprecating these functions, but I also think we should rename My concern with the current name is that it is too generic. It only barely manages to avoid conflicting with the Read and BufReader names in stdlib, and the module scope doesn't disambiguate because the standard library also has an io module. Worse people commonly My preference would be to switch to calling it ImageReader and making the io module internal to the crate. |
I don't share that sentiment of name conflicts outside the library at all. Namespaces exist to avoid that exact problem of complicating the choice for names by collisions. True glob-imports are discouraged in any case. You're free to use any of: use image::io as imio;
use image::io::Reader as ImageReader; |
Perhaps the examples should use this renaming import though. That would be easier to copy&paste which is part of the motivation for having examples in the first place. |
Using renaming imports would be an improvement, but I want to think through a bit more. I guess my concerns are:
|
I agree with renaming I've opened #2243 to implement this. |
Any comments on the questions below are welcome.
In light of #1318 and previously #1291 , #1232 , #1231 , #1072 , #792 (possibly more), I conclude that opening files with the functions in the main module is at least misunderstood but quite possibly a bad interface in itself. It's often not clear how to do combine aspects of these methods by performing parts of them manually—such as how to open a file with a known image type. In that sense these functions are too numerable and too specific at the same time.
io::Reader
intends to fix this by encapsulating the known inputs as an object and then presenting builder-style methods for adjusting the details, independent of whether one opens a file or reads a slice of data from memory.This PR intends to deprecate the utility wrappers in
dynimage
, not the primitive methods inio/free_functions.rs
—guess_format
andload
. This was always planned.The main concern is to find the sweet spot for the scope of the deprecation.
Reader
takes a byte slice as input. For new Rusteceans the generics might be unecessarily confusing.