image-rs / image-png

PNG decoding and encoding library in pure Rust
https://docs.rs/png
Apache License 2.0
347 stars 139 forks source link

Version 0.17.12 makes things no longer Send #470

Closed sophie-h closed 4 months ago

sophie-h commented 4 months ago

Ideally, the version should be retracted since it stops code from building after updating from .11 to .12.

(Also, there is no tag for .12 in the repo)

My build error is the following

error[E0277]: `(dyn for<'a, 'b, 'c, 'd> Fn(&'a [u8], &'b mut [u8], &'c png::common::Info<'d>) + 'static)` cannot be sent between threads safely
   --> loaders/glycin-image-rs/src/bin/glycin-image-rs.rs:116:31
    |
116 | impl LoaderImplementation for ImgDecoder {
    |                               ^^^^^^^^^^ `(dyn for<'a, 'b, 'c, 'd> Fn(&'a [u8], &'b mut [u8], &'c png::common::Info<'d>) + 'static)` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `(dyn for<'a, 'b, 'c, 'd> Fn(&'a [u8], &'b mut [u8], &'c png::common::Info<'d>) + 'static)`
    = note: required for `Unique<(dyn for<'a, 'b, 'c, 'd> Fn(&'a [u8], &'b mut [u8], &'c png::common::Info<'d>) + 'static)>` to implement `Send`
note: required because it appears within the type `Box<dyn Fn(&[u8], &mut [u8], &Info<'d>)>`
   --> /home/herold/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:195:12
    |
195 | pub struct Box<
    |            ^^^
note: required because it appears within the type `Option<Box<dyn Fn(&[u8], &mut [u8], &Info<'d>)>>`
   --> /home/herold/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:569:10
    |
569 | pub enum Option<T> {
    |          ^^^^^^
note: required because it appears within the type `Reader<Cursor<Vec<u8>>>`
   --> /home/herold/.cargo/registry/src/index.crates.io-6f17d22bba15001f/png-0.17.12/src/decoder/mod.rs:356:12
    |
356 | pub struct Reader<R: Read> {
    |            ^^^^^^
note: required because it appears within the type `PngDecoder<Cursor<Vec<u8>>>`
   --> /home/herold/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.24.8/src/codecs/png.rs:112:12
    |
112 | pub struct PngDecoder<R: Read> {
    |            ^^^^^^^^^^
note: required because it appears within the type `ImageRsDecoder<Cursor<Vec<u8>>>`
   --> loaders/glycin-image-rs/src/bin/glycin-image-rs.rs:158:10
fintelia commented 4 months ago

Could you confirm whether #471 fixes things for you? If so, I'll release a version with that change and then yank 0.17.12.

sophie-h commented 4 months ago

Yep, that fixes it, thanks a lot!