From 57e2464fa3ab70ab52a22d08dd2bdfece13a1af8 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:16:38 +1000 Subject: [PATCH 01/12] Explicit `rust-version` Makes it easier to track MSRV breaks --- Cargo.toml | 1 + benchmarks/Cargo.toml | 1 + crates/zune-bin/Cargo.toml | 1 + crates/zune-bmp/Cargo.toml | 2 +- crates/zune-bmp/fuzz/Cargo.toml | 1 + crates/zune-capi/Cargo.toml | 1 + crates/zune-core/Cargo.toml | 1 + crates/zune-farbfeld/Cargo.toml | 1 + crates/zune-gif/Cargo.toml | 1 + crates/zune-hdr/Cargo.toml | 1 + crates/zune-hdr/fuzz/Cargo.toml | 1 + crates/zune-image/Cargo.toml | 1 + crates/zune-imageprocs/Cargo.toml | 2 +- crates/zune-inflate/Cargo.toml | 1 + crates/zune-inflate/fuzz/Cargo.toml | 1 + crates/zune-jpeg/Cargo.toml | 1 + crates/zune-jpeg/fuzz/Cargo.toml | 1 + crates/zune-jpegxl/Cargo.toml | 1 + crates/zune-opencl/Cargo.toml | 1 + crates/zune-png/Cargo.toml | 2 +- crates/zune-png/fuzz/Cargo.toml | 1 + crates/zune-ppm/Cargo.toml | 2 +- crates/zune-ppm/fuzz/Cargo.toml | 1 + crates/zune-psd/Cargo.toml | 2 +- crates/zune-psd/fuzz/Cargo.toml | 1 + crates/zune-python/Cargo.toml | 1 + crates/zune-qoi/Cargo.toml | 2 +- crates/zune-qoi/fuzz/Cargo.toml | 1 + crates/zune-wasm/Cargo.toml | 1 + tests/Cargo.toml | 1 + 30 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b0ebb0514..c4c6435f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0 OR Zlib" repository = "https://github.com/etemesi254/zune-image.git" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index cefb66155..6fdf0caff 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -2,6 +2,7 @@ name = "zune-benches" version = "0.1.0" edition = "2021" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-bin/Cargo.toml b/crates/zune-bin/Cargo.toml index c201d650f..6ca195b16 100644 --- a/crates/zune-bin/Cargo.toml +++ b/crates/zune-bin/Cargo.toml @@ -3,6 +3,7 @@ name = "zune-bin" version = "0.5.0-rc0" edition = "2021" repository = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-bin" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-bmp/Cargo.toml b/crates/zune-bmp/Cargo.toml index c11a6ed81..3bbff22fd 100644 --- a/crates/zune-bmp/Cargo.toml +++ b/crates/zune-bmp/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["bmp", "bmp-decoder", "decoder"] categories = ["multimedia::images"] exclude = ["fuzz/*"] description = "A fast BMP decoder" - +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-bmp/fuzz/Cargo.toml b/crates/zune-bmp/fuzz/Cargo.toml index 76ba25dba..20c9a44f6 100644 --- a/crates/zune-bmp/fuzz/Cargo.toml +++ b/crates/zune-bmp/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-capi/Cargo.toml b/crates/zune-capi/Cargo.toml index 6db4655d2..b11d149d1 100644 --- a/crates/zune-capi/Cargo.toml +++ b/crates/zune-capi/Cargo.toml @@ -3,6 +3,7 @@ name = "zune-capi" version = "0.5.0" edition = "2021" repository = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-capi" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-core/Cargo.toml b/crates/zune-core/Cargo.toml index 0349f68bc..abd8ac535 100644 --- a/crates/zune-core/Cargo.toml +++ b/crates/zune-core/Cargo.toml @@ -8,6 +8,7 @@ repository = "https://github.com/etemesi254/zune-image" keywords = ["image"] categories = ["multimedia::images", "multimedia::encoding"] license = "MIT OR Apache-2.0 OR Zlib" +rust-version = "1.81.0" [features] # When present, we can use std facilities to detect diff --git a/crates/zune-farbfeld/Cargo.toml b/crates/zune-farbfeld/Cargo.toml index 6de4f2e6e..df2b59919 100644 --- a/crates/zune-farbfeld/Cargo.toml +++ b/crates/zune-farbfeld/Cargo.toml @@ -8,6 +8,7 @@ homepage = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-farbfe keywords = ["image"] categories = ["multimedia::images", "multimedia::encoding"] license = "MIT OR Apache-2.0 OR Zlib" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] diff --git a/crates/zune-gif/Cargo.toml b/crates/zune-gif/Cargo.toml index 1de832111..ab9550b5c 100644 --- a/crates/zune-gif/Cargo.toml +++ b/crates/zune-gif/Cargo.toml @@ -3,6 +3,7 @@ name = "zune-gif" version = "0.5.0-rc0" edition = "2021" repository = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-gif" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-hdr/Cargo.toml b/crates/zune-hdr/Cargo.toml index 2cb350358..a4da88709 100644 --- a/crates/zune-hdr/Cargo.toml +++ b/crates/zune-hdr/Cargo.toml @@ -8,6 +8,7 @@ homepage = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-hdr" keywords = ["image"] categories = ["multimedia::images", "multimedia::encoding", ] license = "MIT OR Apache-2.0 OR Zlib" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] diff --git a/crates/zune-hdr/fuzz/Cargo.toml b/crates/zune-hdr/fuzz/Cargo.toml index 2b4c8d01a..9c694c850 100644 --- a/crates/zune-hdr/fuzz/Cargo.toml +++ b/crates/zune-hdr/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-image/Cargo.toml b/crates/zune-image/Cargo.toml index 26c1416be..c47945f8b 100644 --- a/crates/zune-image/Cargo.toml +++ b/crates/zune-image/Cargo.toml @@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0 OR Zlib" keywords = ["image", "decoder", "encoder", "image-processing"] categories = ["multimedia::images"] description = "An image library, contiaining necessary capabilities to decode, manipulate and encode images" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] # Single based image decoders and encoders diff --git a/crates/zune-imageprocs/Cargo.toml b/crates/zune-imageprocs/Cargo.toml index 496f47a7f..426fced80 100644 --- a/crates/zune-imageprocs/Cargo.toml +++ b/crates/zune-imageprocs/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0 OR Zlib" keywords = ["image", "image-processing"] categories = ["multimedia::images"] description = "Common image processing routines for zune-image" - +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-inflate/Cargo.toml b/crates/zune-inflate/Cargo.toml index 8762ee1e0..11e689d65 100644 --- a/crates/zune-inflate/Cargo.toml +++ b/crates/zune-inflate/Cargo.toml @@ -9,6 +9,7 @@ homepage = "https://github.com/etemesi254/zune-image/tree/main/zune-inflate" keywords = ["compression", "inflate", "deflate"] categories = ["compression"] license = "MIT OR Apache-2.0 OR Zlib" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] diff --git a/crates/zune-inflate/fuzz/Cargo.toml b/crates/zune-inflate/fuzz/Cargo.toml index e761efebf..370983c84 100644 --- a/crates/zune-inflate/fuzz/Cargo.toml +++ b/crates/zune-inflate/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-jpeg/Cargo.toml b/crates/zune-jpeg/Cargo.toml index fd8797e3c..67dd428cb 100644 --- a/crates/zune-jpeg/Cargo.toml +++ b/crates/zune-jpeg/Cargo.toml @@ -9,6 +9,7 @@ keywords = ["jpeg", "jpeg-decoder", "decoder"] categories = ["multimedia::images"] exclude = ["/benches/images/*", "/tests/*", "/.idea/*", "/.gradle/*", "/test-images/*", "fuzz/*"] description = "A fast, correct and safe jpeg decoder" +rust-version = "1.81.0" [lints.rust] # Disable feature checker for fuzzing since it's used and cargo doesn't diff --git a/crates/zune-jpeg/fuzz/Cargo.toml b/crates/zune-jpeg/fuzz/Cargo.toml index 2574dcded..d3983d162 100644 --- a/crates/zune-jpeg/fuzz/Cargo.toml +++ b/crates/zune-jpeg/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-jpegxl/Cargo.toml b/crates/zune-jpegxl/Cargo.toml index 8d51d4043..9cc9b178f 100644 --- a/crates/zune-jpegxl/Cargo.toml +++ b/crates/zune-jpegxl/Cargo.toml @@ -9,6 +9,7 @@ keywords = ["jpeg-xl", "jpeg-xl-decoder", "decoder", "jxl"] categories = ["multimedia::images"] exclude = [] description = "A simple, fast and fully safe modular jxl encoder" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-opencl/Cargo.toml b/crates/zune-opencl/Cargo.toml index 49771e598..9264d78db 100644 --- a/crates/zune-opencl/Cargo.toml +++ b/crates/zune-opencl/Cargo.toml @@ -3,6 +3,7 @@ name = "zune-opencl" version = "0.4.0" edition = "2021" repository = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-opencl" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-png/Cargo.toml b/crates/zune-png/Cargo.toml index 7f33cec64..06676bc72 100644 --- a/crates/zune-png/Cargo.toml +++ b/crates/zune-png/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["png", "png-decoder", "decoder"] categories = ["multimedia::images"] exclude = ["/benches/images/*", "/tests/*", "/.idea/*", "/.gradle/*", "/test-images/*", "fuzz/*"] description = "A fast, correct and safe png decoder" - +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-png/fuzz/Cargo.toml b/crates/zune-png/fuzz/Cargo.toml index d53edaaef..865d48b85 100644 --- a/crates/zune-png/fuzz/Cargo.toml +++ b/crates/zune-png/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-ppm/Cargo.toml b/crates/zune-ppm/Cargo.toml index 647b2a21c..babcf2ff0 100644 --- a/crates/zune-ppm/Cargo.toml +++ b/crates/zune-ppm/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["ppm", "ppm-decoder", "decoder"] categories = ["multimedia::images"] exclude = ["fuzz/*"] description = "Portable Pixmap and Portable Floatmap Format Decoder and Encoder" - +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-ppm/fuzz/Cargo.toml b/crates/zune-ppm/fuzz/Cargo.toml index 9a8aa69fb..a96a8e58a 100644 --- a/crates/zune-ppm/fuzz/Cargo.toml +++ b/crates/zune-ppm/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-psd/Cargo.toml b/crates/zune-psd/Cargo.toml index 7ebd476d8..d648c5103 100644 --- a/crates/zune-psd/Cargo.toml +++ b/crates/zune-psd/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["psd", "psd-decoder", "decoder"] categories = ["multimedia::images"] exclude = ["fuzz/*"] description = "Photoshop Simple PSD decoder" - +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/zune-psd/fuzz/Cargo.toml b/crates/zune-psd/fuzz/Cargo.toml index 454127867..ee34a711e 100644 --- a/crates/zune-psd/fuzz/Cargo.toml +++ b/crates/zune-psd/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-python/Cargo.toml b/crates/zune-python/Cargo.toml index 3521d1734..4830eb3c5 100644 --- a/crates/zune-python/Cargo.toml +++ b/crates/zune-python/Cargo.toml @@ -3,6 +3,7 @@ name = "zune-python" version = "0.4.0" edition = "2021" repository = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-python" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/crates/zune-qoi/Cargo.toml b/crates/zune-qoi/Cargo.toml index a95e2d890..7b95578c9 100644 --- a/crates/zune-qoi/Cargo.toml +++ b/crates/zune-qoi/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["qoi", "qoi-decoder", "decoder", "qoi-encoder", "encoder"] categories = ["multimedia::images"] exclude = ["fuzz/*"] description = "Quite Ok Image (QOI) decoder and encoder part of the zune-image family" - +rust-version = "1.81.0" [features] log = ["zune-core/log"] diff --git a/crates/zune-qoi/fuzz/Cargo.toml b/crates/zune-qoi/fuzz/Cargo.toml index 6a625dcf4..a66e42549 100644 --- a/crates/zune-qoi/fuzz/Cargo.toml +++ b/crates/zune-qoi/fuzz/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.0" authors = ["Automatically generated"] publish = false edition = "2018" +rust-version = "1.81.0" [package.metadata] cargo-fuzz = true diff --git a/crates/zune-wasm/Cargo.toml b/crates/zune-wasm/Cargo.toml index 41ee624a3..fe22fd50f 100644 --- a/crates/zune-wasm/Cargo.toml +++ b/crates/zune-wasm/Cargo.toml @@ -6,6 +6,7 @@ authors = ["caleb "] edition = "2021" license = "MIT OR Apache-2.0 OR Zlib" repository = "https://github.com/etemesi254/zune-image/tree/dev/crates/zune-wasm" +rust-version = "1.81.0" [lib] crate-type = ["cdylib", "rlib"] diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 44d527f48..9aa233e7b 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -2,6 +2,7 @@ name = "zune-tests" version = "0.1.0" edition = "2021" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 6bdef424555e6c287552e1ded5f1e79c791d3757 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:17:28 +1000 Subject: [PATCH 02/12] Add `Cargo.lock` to .gitignore Not currently checked in, adding here ensures it wont be accidentally --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cb151c43d..64c9a33dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -**/.DS_Store \ No newline at end of file +**/.DS_Store +Cargo.lock \ No newline at end of file From 51d8a7f047253157f3c7bbe9b42f43b3ee5b0dec Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:20:24 +1000 Subject: [PATCH 03/12] `zune-bmp` - Remove `std` feature as no longer required --- crates/zune-bmp/Cargo.toml | 4 +++- crates/zune-bmp/src/lib.rs | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/zune-bmp/Cargo.toml b/crates/zune-bmp/Cargo.toml index 3bbff22fd..df1e09897 100644 --- a/crates/zune-bmp/Cargo.toml +++ b/crates/zune-bmp/Cargo.toml @@ -15,9 +15,11 @@ rust-version = "1.81.0" [features] log = ["zune-core/log"] -std = ["zune-core/std"] rgb_inverse = [] [dependencies] zune-core = { version = "0.5.0-rc1", path = "../zune-core" } log = "0.4.21" + +[dev-dependencies] +zune-core = { version = "0.5.0-rc1", path = "../zune-core", features = ["std"] } \ No newline at end of file diff --git a/crates/zune-bmp/src/lib.rs b/crates/zune-bmp/src/lib.rs index 16c26e28d..059fe3ae6 100644 --- a/crates/zune-bmp/src/lib.rs +++ b/crates/zune-bmp/src/lib.rs @@ -54,9 +54,6 @@ //! use zune_bmp::BmpDecoder; //! // read from a file //! let source = BufReader::new(File::open("./image.bmp").unwrap()); -//! // only run when std is enabled, otherwise zune_core doesn't implement the ZByteReader trait -//! // on File since it doesn't exist in `no_std` land -//! #[cfg(feature = "std")] //! let decoder = BmpDecoder::new(source); //! //! ``` @@ -71,9 +68,8 @@ //! benchmark just in case you think it's slowing you down in any way. //! #![no_std] -#![macro_use] -extern crate alloc; +extern crate alloc; extern crate core; pub use zune_core; From bf32d64fed9c6493de607be6220819297ba1e687 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:21:23 +1000 Subject: [PATCH 04/12] `zune-core` - Allow `serde` feature on `no_std` - Switch to `core` implicit prelude --- crates/zune-core/Cargo.toml | 2 +- crates/zune-core/src/bytestream/reader.rs | 2 +- crates/zune-core/src/bytestream/reader/std_readers.rs | 1 + crates/zune-core/src/lib.rs | 7 +++++-- crates/zune-core/src/options/decoder.rs | 10 +++++----- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/zune-core/Cargo.toml b/crates/zune-core/Cargo.toml index abd8ac535..d65fcfea5 100644 --- a/crates/zune-core/Cargo.toml +++ b/crates/zune-core/Cargo.toml @@ -20,4 +20,4 @@ std = [] [dependencies] log = { version = "0.4.17", optional = true } -serde = { version = "1.0.52", optional = true } +serde = { version = "1.0.52", optional = true, default-features = false } diff --git a/crates/zune-core/src/bytestream/reader.rs b/crates/zune-core/src/bytestream/reader.rs index 8d49c4bf5..de5ad204e 100644 --- a/crates/zune-core/src/bytestream/reader.rs +++ b/crates/zune-core/src/bytestream/reader.rs @@ -453,6 +453,6 @@ where fn read(&mut self, buf: &mut [u8]) -> std::io::Result { use std::io::ErrorKind; self.read_bytes(buf) - .map_err(|e| std::io::Error::new(ErrorKind::Other, format!("{:?}", e))) + .map_err(|e| std::io::Error::new(ErrorKind::Other, alloc::format!("{:?}", e))) } } diff --git a/crates/zune-core/src/bytestream/reader/std_readers.rs b/crates/zune-core/src/bytestream/reader/std_readers.rs index 014d0bd32..730dee263 100644 --- a/crates/zune-core/src/bytestream/reader/std_readers.rs +++ b/crates/zune-core/src/bytestream/reader/std_readers.rs @@ -1,5 +1,6 @@ #![cfg(feature = "std")] +use alloc::vec::Vec; use std::io; use std::io::SeekFrom; diff --git a/crates/zune-core/src/lib.rs b/crates/zune-core/src/lib.rs index 77355f934..4f7450318 100644 --- a/crates/zune-core/src/lib.rs +++ b/crates/zune-core/src/lib.rs @@ -43,11 +43,14 @@ //! //! //! -#![cfg_attr(not(feature = "std"), no_std)] -#![macro_use] +#![no_std] + extern crate alloc; extern crate core; +#[cfg(feature = "std")] +extern crate std; + #[cfg(not(feature = "log"))] pub mod log; diff --git a/crates/zune-core/src/options/decoder.rs b/crates/zune-core/src/options/decoder.rs index 6093c70ec..177957a24 100644 --- a/crates/zune-core/src/options/decoder.rs +++ b/crates/zune-core/src/options/decoder.rs @@ -450,7 +450,7 @@ impl DecoderOptions { // where we can do runtime check if feature is present #[cfg(feature = "std")] { - if is_x86_feature_detected!("sse2") { + if std::is_x86_feature_detected!("sse2") { return true; } } @@ -483,7 +483,7 @@ impl DecoderOptions { // where we can do runtime check if feature is present #[cfg(feature = "std")] { - if is_x86_feature_detected!("sse3") { + if std::is_x86_feature_detected!("sse3") { return true; } } @@ -515,7 +515,7 @@ impl DecoderOptions { // where we can do runtime check if feature is present #[cfg(feature = "std")] { - if is_x86_feature_detected!("sse4.1") { + if std::is_x86_feature_detected!("sse4.1") { return true; } } @@ -547,7 +547,7 @@ impl DecoderOptions { // where we can do runtime check if feature is present #[cfg(feature = "std")] { - if is_x86_feature_detected!("avx") { + if std::is_x86_feature_detected!("avx") { return true; } } @@ -579,7 +579,7 @@ impl DecoderOptions { // where we can do runtime check if feature is present #[cfg(feature = "std")] { - if is_x86_feature_detected!("avx2") { + if std::is_x86_feature_detected!("avx2") { return true; } } From 151548d86694367eb53a005f367e3deab1ca7009 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:21:44 +1000 Subject: [PATCH 05/12] `zune-farbfeld` - Remove unused `macro_use` --- crates/zune-farbfeld/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/zune-farbfeld/src/lib.rs b/crates/zune-farbfeld/src/lib.rs index 167be93c6..01ffeb559 100644 --- a/crates/zune-farbfeld/src/lib.rs +++ b/crates/zune-farbfeld/src/lib.rs @@ -24,7 +24,7 @@ //! //! #![no_std] -#![macro_use] + extern crate alloc; pub use decoder::*; From 5e64594ff4222125698f90571740656b181e4fd9 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:22:06 +1000 Subject: [PATCH 06/12] `zune-gif` - Add `no_std` support --- crates/zune-gif/src/decoder.rs | 2 ++ crates/zune-gif/src/errors.rs | 4 ++-- crates/zune-gif/src/lib.rs | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/zune-gif/src/decoder.rs b/crates/zune-gif/src/decoder.rs index f1d2e6e13..c0bd09658 100644 --- a/crates/zune-gif/src/decoder.rs +++ b/crates/zune-gif/src/decoder.rs @@ -1,3 +1,5 @@ +use alloc::vec::Vec; + use zune_core::bytestream::{ZByteReaderTrait, ZReader}; use zune_core::log::trace; use zune_core::options::DecoderOptions; diff --git a/crates/zune-gif/src/errors.rs b/crates/zune-gif/src/errors.rs index c2f713a8b..0de97b1b6 100644 --- a/crates/zune-gif/src/errors.rs +++ b/crates/zune-gif/src/errors.rs @@ -1,5 +1,5 @@ use core::fmt::Debug; -use std::fmt::Formatter; +use core::fmt::Formatter; use zune_core::bytestream::ZByteIoError; @@ -18,7 +18,7 @@ pub enum GifDecoderErrors { TooSmallSize(usize, usize) } impl Debug for GifDecoderErrors { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { match self { GifDecoderErrors::NotAGif => { writeln!(f, "Not a gif, magic bytes didn't match") diff --git a/crates/zune-gif/src/lib.rs b/crates/zune-gif/src/lib.rs index 622b298db..5f953b6d5 100644 --- a/crates/zune-gif/src/lib.rs +++ b/crates/zune-gif/src/lib.rs @@ -1,3 +1,9 @@ +#![no_std] + +#[macro_use] +extern crate alloc; +extern crate core; + mod decoder; mod enums; mod errors; From c0167f63520d8868911e4f2c682b63b96b0cd3b8 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:22:34 +1000 Subject: [PATCH 07/12] `zune-inflate` - Remove unused `std` feature - Switch to `core` implicit prelude --- crates/zune-inflate/Cargo.toml | 4 +--- crates/zune-inflate/src/errors.rs | 3 +-- crates/zune-inflate/src/lib.rs | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/zune-inflate/Cargo.toml b/crates/zune-inflate/Cargo.toml index 11e689d65..b92b87ad0 100644 --- a/crates/zune-inflate/Cargo.toml +++ b/crates/zune-inflate/Cargo.toml @@ -15,10 +15,8 @@ rust-version = "1.81.0" [features] zlib = ["simd-adler32"] gzip = [] -std = ["simd-adler32/std"] - -default = ["zlib", "gzip", "std"] +default = ["zlib", "gzip"] [dependencies] simd-adler32 = { version = "0.3.4", optional = true, default-features = false } diff --git a/crates/zune-inflate/src/errors.rs b/crates/zune-inflate/src/errors.rs index 1711ab60d..fd645213c 100644 --- a/crates/zune-inflate/src/errors.rs +++ b/crates/zune-inflate/src/errors.rs @@ -114,5 +114,4 @@ impl Display for InflateDecodeErrors { } } -#[cfg(feature = "std")] -impl std::error::Error for InflateDecodeErrors {} +impl core::error::Error for InflateDecodeErrors {} diff --git a/crates/zune-inflate/src/lib.rs b/crates/zune-inflate/src/lib.rs index 6edc58952..7b2e68d11 100644 --- a/crates/zune-inflate/src/lib.rs +++ b/crates/zune-inflate/src/lib.rs @@ -86,7 +86,8 @@ //! [libdeflater]: https://github.com/adamkewley/libdeflater //! [flate2-rs]: https://github.com/rust-lang/flate2-rs //! -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] + extern crate alloc; pub use crate::decoder::{DeflateDecoder, DeflateOptions}; From 6fab3457044538fa6da6fa699b3359bdc373d7e4 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:23:13 +1000 Subject: [PATCH 08/12] `zune-jpeg` - Remove `std` feature as no longer used - Switch to `core` implicit prelude --- crates/zune-jpeg/Cargo.toml | 3 +-- crates/zune-jpeg/src/errors.rs | 3 +-- crates/zune-jpeg/src/lib.rs | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/zune-jpeg/Cargo.toml b/crates/zune-jpeg/Cargo.toml index 67dd428cb..ccc97453b 100644 --- a/crates/zune-jpeg/Cargo.toml +++ b/crates/zune-jpeg/Cargo.toml @@ -21,9 +21,8 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] } [features] x86 = [] neon = [] -std = ["zune-core/std"] log = ["zune-core/log"] -default = ["x86", "neon", "std"] +default = ["x86", "neon"] [dependencies] diff --git a/crates/zune-jpeg/src/errors.rs b/crates/zune-jpeg/src/errors.rs index 1410961e0..461df4257 100644 --- a/crates/zune-jpeg/src/errors.rs +++ b/crates/zune-jpeg/src/errors.rs @@ -53,8 +53,7 @@ pub enum DecodeErrors { IoErrors(ZByteIoError) } -#[cfg(feature = "std")] -impl std::error::Error for DecodeErrors {} +impl core::error::Error for DecodeErrors {} impl From<&'static str> for DecodeErrors { fn from(data: &'static str) -> Self { diff --git a/crates/zune-jpeg/src/lib.rs b/crates/zune-jpeg/src/lib.rs index 59143bec9..c91605b2d 100644 --- a/crates/zune-jpeg/src/lib.rs +++ b/crates/zune-jpeg/src/lib.rs @@ -102,8 +102,9 @@ // no_std compatibility #![deny(clippy::std_instead_of_alloc, clippy::alloc_instead_of_core)] #![cfg_attr(not(any(feature = "x86", feature = "neon")), forbid(unsafe_code))] -#![cfg_attr(not(feature = "std"), no_std)] -#![macro_use] +#![no_std] + +#[macro_use] extern crate alloc; extern crate core; From 7cfde0bd0671f2206ef672ca31db685879810dae Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:24:03 +1000 Subject: [PATCH 09/12] `zune-jpegxl` - Switch to `core` implicit prelude - Ensure `threads` activates `std` --- crates/zune-jpegxl/Cargo.toml | 2 +- crates/zune-jpegxl/src/errors.rs | 3 +-- crates/zune-jpegxl/src/lib.rs | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/zune-jpegxl/Cargo.toml b/crates/zune-jpegxl/Cargo.toml index 9cc9b178f..dee9b8fd9 100644 --- a/crates/zune-jpegxl/Cargo.toml +++ b/crates/zune-jpegxl/Cargo.toml @@ -18,7 +18,7 @@ rust-version = "1.81.0" zune-core = { version = "^0.5.0-rc0", path = "../zune-core" } [features] -threads = [] +threads = ["std"] std = [] log = ["zune-core/log"] default = ["threads", "std"] diff --git a/crates/zune-jpegxl/src/errors.rs b/crates/zune-jpegxl/src/errors.rs index ce4b5eea8..84aa5820f 100644 --- a/crates/zune-jpegxl/src/errors.rs +++ b/crates/zune-jpegxl/src/errors.rs @@ -90,5 +90,4 @@ impl core::fmt::Display for JxlEncodeErrors { } } -#[cfg(feature = "std")] -impl std::error::Error for JxlEncodeErrors {} +impl core::error::Error for JxlEncodeErrors {} diff --git a/crates/zune-jpegxl/src/lib.rs b/crates/zune-jpegxl/src/lib.rs index 7ce5855ce..f7e658e4b 100644 --- a/crates/zune-jpegxl/src/lib.rs +++ b/crates/zune-jpegxl/src/lib.rs @@ -81,11 +81,14 @@ //! ``` //! #![forbid(unsafe_code)] -#![cfg_attr(not(feature = "std"), no_std)] -#![macro_use] +#![no_std] + extern crate alloc; extern crate core; +#[cfg(feature = "std")] +extern crate std; + pub use encoder::JxlSimpleEncoder; pub use errors::JxlEncodeErrors; From 4fe2cebfb1d932d649bbc6455572900a973c3a53 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:25:01 +1000 Subject: [PATCH 10/12] `zune-png` - Switch to `core` implicit prelude --- crates/zune-png/src/error.rs | 3 +-- crates/zune-png/src/filters/sse4.rs | 6 +++--- crates/zune-png/src/lib.rs | 6 +++++- crates/zune-png/src/utils.rs | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/zune-png/src/error.rs b/crates/zune-png/src/error.rs index 399c4f17d..4566575fb 100644 --- a/crates/zune-png/src/error.rs +++ b/crates/zune-png/src/error.rs @@ -39,8 +39,7 @@ impl Display for PngDecodeErrors { } } -#[cfg(feature = "std")] -impl std::error::Error for PngDecodeErrors {} +impl core::error::Error for PngDecodeErrors {} impl Debug for PngDecodeErrors { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { diff --git a/crates/zune-png/src/filters/sse4.rs b/crates/zune-png/src/filters/sse4.rs index e2bb0c981..2838d6db5 100644 --- a/crates/zune-png/src/filters/sse4.rs +++ b/crates/zune-png/src/filters/sse4.rs @@ -191,7 +191,7 @@ unsafe fn de_filter_sub_generic_sse2(raw: &[u8], current: &mu pub fn de_filter_sub_sse2(raw: &[u8], current: &mut [u8]) { #[cfg(feature = "std")] { - if !is_x86_feature_detected!("sse2") { + if !std::is_x86_feature_detected!("sse2") { panic!("Internal error, calling platform specific function where not supported") } } @@ -268,7 +268,7 @@ unsafe fn de_filter_paeth_sse41_inner( pub fn de_filter_paeth_sse41(prev_row: &[u8], raw: &[u8], current: &mut [u8]) { #[cfg(feature = "std")] { - if !is_x86_feature_detected!("sse4.1") { + if !std::is_x86_feature_detected!("sse4.1") { panic!("Internal error, calling platform specific function where not supported") } } @@ -325,7 +325,7 @@ unsafe fn defilter_avg_sse2_inner( pub fn defilter_avg_sse(prev_row: &[u8], raw: &[u8], current: &mut [u8]) { #[cfg(feature = "std")] { - if !is_x86_feature_detected!("sse2") { + if !std::is_x86_feature_detected!("sse2") { panic!("Internal error, calling platform specific function where not supported") } } diff --git a/crates/zune-png/src/lib.rs b/crates/zune-png/src/lib.rs index 0b086744e..db7848e8e 100644 --- a/crates/zune-png/src/lib.rs +++ b/crates/zune-png/src/lib.rs @@ -160,11 +160,15 @@ //! //! //! -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] #![allow(clippy::op_ref, clippy::identity_op)] + extern crate alloc; extern crate core; +#[cfg(feature = "std")] +extern crate std; + #[cfg(feature = "std")] pub use apng::post_process_image; pub use apng::{BlendOp, DisposeOp}; diff --git a/crates/zune-png/src/utils.rs b/crates/zune-png/src/utils.rs index 1633e4dcf..2419e7961 100644 --- a/crates/zune-png/src/utils.rs +++ b/crates/zune-png/src/utils.rs @@ -36,12 +36,12 @@ fn convert_be_to_le_u16(out: &mut [u8], _use_sse4: bool) { #[cfg(feature = "std")] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - if _use_sse4 && is_x86_feature_detected!("avx2") { + if _use_sse4 && std::is_x86_feature_detected!("avx2") { unsafe { return avx::convert_be_to_ne_avx(out); }; } - if _use_sse4 && is_x86_feature_detected!("ssse3") { + if _use_sse4 && std::is_x86_feature_detected!("ssse3") { unsafe { return sse::convert_be_to_ne_sse4(out); } From 9dd0f716c0b3eb50cca9cc8b70c76b80a19b5287 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:25:35 +1000 Subject: [PATCH 11/12] `zune-qoi` - Remove unused `std` feature --- crates/zune-qoi/Cargo.toml | 3 +-- crates/zune-qoi/src/errors.rs | 6 ++---- crates/zune-qoi/src/lib.rs | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/zune-qoi/Cargo.toml b/crates/zune-qoi/Cargo.toml index 7b95578c9..b2bd71e43 100644 --- a/crates/zune-qoi/Cargo.toml +++ b/crates/zune-qoi/Cargo.toml @@ -13,8 +13,7 @@ rust-version = "1.81.0" [features] log = ["zune-core/log"] -std = ["zune-core/std"] -default = ["std", "log"] +default = ["log"] [dependencies] zune-core = { path = "../zune-core", version = "^0.5.0-rc0" } diff --git a/crates/zune-qoi/src/errors.rs b/crates/zune-qoi/src/errors.rs index 0b437e4ba..9b0a12d7c 100644 --- a/crates/zune-qoi/src/errors.rs +++ b/crates/zune-qoi/src/errors.rs @@ -147,11 +147,9 @@ impl Display for QoiErrors { } } -#[cfg(feature = "std")] -impl std::error::Error for QoiEncodeErrors {} +impl core::error::Error for QoiEncodeErrors {} -#[cfg(feature = "std")] -impl std::error::Error for QoiErrors {} +impl core::error::Error for QoiErrors {} impl From for QoiEncodeErrors { fn from(value: ZByteIoError) -> Self { diff --git a/crates/zune-qoi/src/lib.rs b/crates/zune-qoi/src/lib.rs index 6e687d549..707e88871 100644 --- a/crates/zune-qoi/src/lib.rs +++ b/crates/zune-qoi/src/lib.rs @@ -17,8 +17,8 @@ //! ## `no_std` //! You can use `no_std` with alloc feature to compile for `no_std` endpoints -#![cfg_attr(not(feature = "std"), no_std)] -#![macro_use] +#![no_std] + extern crate alloc; extern crate core; From 1dd6c150aa80d0513a91d0992b562034f2a8d7d8 Mon Sep 17 00:00:00 2001 From: Zac Harrold Date: Tue, 20 May 2025 08:26:03 +1000 Subject: [PATCH 12/12] Update `no_std` CI Task Test all `no_std` compatible features --- .github/workflows/no_std.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/no_std.yml b/.github/workflows/no_std.yml index d3d964bb5..c87679d63 100644 --- a/.github/workflows/no_std.yml +++ b/.github/workflows/no_std.yml @@ -24,15 +24,16 @@ jobs: # Target below does not have a standard library - run: rustup target add x86_64-unknown-uefi # Below targets run in no-std environments - - run: cargo build -p zune-core --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-inflate --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-png --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-ppm --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-qoi --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-farbfeld --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-psd --target x86_64-unknown-uefi --no-default-features - - run: cargo build -p zune-bmp --target x86_64-unknown-uefi --no-default-features - + - run: cargo build -p zune-core --target x86_64-unknown-uefi --no-default-features --features log,serde + - run: cargo build -p zune-inflate --target x86_64-unknown-uefi --no-default-features --features zlib,gzip + - run: cargo build -p zune-jpeg --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-png --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-ppm --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-qoi --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-farbfeld --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-psd --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-bmp --target x86_64-unknown-uefi --no-default-features --features log,rgb_inverse + - run: cargo build -p zune-gif --target x86_64-unknown-uefi --no-default-features --features log + - run: cargo build -p zune-jpegxl --target x86_64-unknown-uefi --no-default-features --features log