From f153093e5ad4529cce31feece07e1376727c4c62 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Wed, 30 Oct 2024 22:08:44 +0000 Subject: [PATCH 1/2] [parser] [object] Revert use of inspect method for more Rust compiler compatibility - Result::inspect and Option::inspect were introduced in 1.76.0 --- object/src/mem.rs | 12 ++++++++---- parser/src/stateful/decode.rs | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/object/src/mem.rs b/object/src/mem.rs index 5607d792..9cdd8ff6 100644 --- a/object/src/mem.rs +++ b/object/src/mem.rs @@ -940,10 +940,11 @@ where /// reporting whether it was present. pub fn remove_element_by_name(&mut self, name: &str) -> Result { let tag = self.lookup_name(name)?; - Ok(self.entries.remove(&tag).is_some()).inspect(|&removed| { + Ok(self.entries.remove(&tag).is_some()).map(|removed| { if removed { self.len = Length::UNDEFINED; } + removed }) } @@ -951,8 +952,9 @@ where pub fn take_element(&mut self, tag: Tag) -> Result> { self.entries .remove(&tag) - .inspect(|_| { + .map(|e| { self.len = Length::UNDEFINED; + e }) .context(NoSuchDataElementTagSnafu { tag }) } @@ -961,8 +963,9 @@ where /// if it is present, /// returns `None` otherwise. pub fn take(&mut self, tag: Tag) -> Option> { - self.entries.remove(&tag).inspect(|_| { + self.entries.remove(&tag).map(|e| { self.len = Length::UNDEFINED; + e }) } @@ -974,8 +977,9 @@ where let tag = self.lookup_name(name)?; self.entries .remove(&tag) - .inspect(|_| { + .map(|e| { self.len = Length::UNDEFINED; + e }) .with_context(|| NoSuchDataElementAliasSnafu { tag, diff --git a/parser/src/stateful/decode.rs b/parser/src/stateful/decode.rs index 1e5d8dd6..c0a20704 100644 --- a/parser/src/stateful/decode.rs +++ b/parser/src/stateful/decode.rs @@ -913,8 +913,9 @@ where .context(DecodeItemHeaderSnafu { position: self.position, }) - .inspect(|_| { + .map(|header| { self.position += 8; + header }) .map_err(From::from) } From 12a03ae79719d4c193b613ee638cc8e03d9a869e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Thu, 31 Oct 2024 11:33:19 +0100 Subject: [PATCH 2/2] Set minimal rust version to 1.72 --- .github/workflows/rust.yml | 36 ++++++++++++++++++++++++----- README.md | 3 +++ clippy.toml | 1 + core/Cargo.toml | 1 + dictionary-std/Cargo.toml | 1 + dump/Cargo.toml | 1 + encoding/Cargo.toml | 1 + fromimage/Cargo.toml | 1 + object/Cargo.toml | 1 + object/src/lib.rs | 2 +- parent/Cargo.toml | 1 + parser/Cargo.toml | 1 + pixeldata/Cargo.toml | 1 + pixeldata/src/attribute.rs | 7 +++--- toimage/Cargo.toml | 1 + transfer-syntax-registry/Cargo.toml | 1 + ul/Cargo.toml | 1 + 17 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 clippy.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 750d576a..a92141d7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,6 +14,7 @@ jobs: strategy: matrix: rust: + - 1.72.0 - stable - beta steps: @@ -24,16 +25,39 @@ jobs: components: clippy cache: true # test project with default + extra features - - run: cargo test --features image,ndarray,sop-class,rle,cli,jpegxl + - if: matrix.rust == 'stable' || matrix.rust == 'beta' + run: cargo test --features image,ndarray,sop-class,rle,cli,jpegxl # test dicom-pixeldata with openjp2 - - run: cargo test -p dicom-pixeldata --features openjp2 + - if: matrix.rust == 'stable' || matrix.rust == 'beta' + run: cargo test -p dicom-pixeldata --features openjp2 # test dicom-pixeldata with openjpeg-sys and charls - - run: cargo test -p dicom-pixeldata --features openjpeg-sys,charls + - if: matrix.rust == 'stable' || matrix.rust == 'beta' + run: cargo test -p dicom-pixeldata --features openjpeg-sys,charls # test dicom-pixeldata with gdcm-rs - - run: cargo test -p dicom-pixeldata --features gdcm + - if: matrix.rust == 'stable' || matrix.rust == 'beta' + run: cargo test -p dicom-pixeldata --features gdcm # test dicom-pixeldata without default features - - run: cargo test -p dicom-pixeldata --no-default-features - - run: cargo test -p dicom-ul --features async + - if: matrix.rust == 'stable' || matrix.rust == 'beta' + run: cargo test -p dicom-pixeldata --no-default-features + # test dicom-ul with async feature + - if: matrix.rust == 'stable' || matrix.rust == 'beta' + run: cargo test -p dicom-ul --features async + # test library projects with minimum rust version + - if: matrix.rust == '1.72.0' + run: | + cargo test -p dicom-core + cargo test -p dicom-encoding + cargo test -p dicom-dictionary-std + cargo test -p dicom-parser + cargo test -p dicom-transfer-syntax-registry + cargo test -p dicom-object + cargo test -p dicom-dump --no-default-features --features sop-class + cargo test -p dicom-json + cargo test -p dicom-ul + cargo test -p dicom-pixeldata + cargo check -p dicom + env: + RUSTFLAGS: -W warnings # run Clippy with stable toolchain - if: matrix.rust == 'stable' run: cargo clippy diff --git a/README.md b/README.md index 2df926ab..9aaaf9a4 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,9 @@ no other development dependencies are necessary unless certain extensions are included via Cargo features. Consult each crate for guidelines on selecting features to suit your needs. +Minimum supported Rust version is 1.72.0 and only applies to the library crates with default features. +Binary crates and extra features may require a newer version of Rust. + ## Roadmap & Contributing This project is under active development. diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..e6d25b89 --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +msrv="1.72.0" \ No newline at end of file diff --git a/core/Cargo.toml b/core/Cargo.toml index af24dc0d..c93a44f6 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho "] description = "Efficient and practical core library for DICOM compliant systems" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" keywords = ["dicom"] diff --git a/dictionary-std/Cargo.toml b/dictionary-std/Cargo.toml index d6a04e3e..60e584c0 100644 --- a/dictionary-std/Cargo.toml +++ b/dictionary-std/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.0" authors = ["Eduardo Pinho "] description = "Standard DICOM attribute dictionary" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" keywords = ["dicom", "dictionary"] diff --git a/dump/Cargo.toml b/dump/Cargo.toml index c016e159..c37d225a 100644 --- a/dump/Cargo.toml +++ b/dump/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho "] description = "A CLI tool for inspecting DICOM files" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" categories = ["command-line-utilities"] diff --git a/encoding/Cargo.toml b/encoding/Cargo.toml index 0315960c..04fc1789 100644 --- a/encoding/Cargo.toml +++ b/encoding/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho "] description = "DICOM encoding and decoding primitives" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" categories = ["encoding"] diff --git a/fromimage/Cargo.toml b/fromimage/Cargo.toml index 34556d5d..b6a6d5c0 100644 --- a/fromimage/Cargo.toml +++ b/fromimage/Cargo.toml @@ -2,6 +2,7 @@ name = "dicom-fromimage" version = "0.7.0" edition = "2018" +rust-version = "1.72.0" authors = ["Eduardo Pinho "] description = "A CLI tool for replacing the image content from DICOM files" license = "MIT OR Apache-2.0" diff --git a/object/Cargo.toml b/object/Cargo.toml index 5025d640..fd4bb66d 100644 --- a/object/Cargo.toml +++ b/object/Cargo.toml @@ -3,6 +3,7 @@ name = "dicom-object" version = "0.7.1" authors = ["Eduardo Pinho "] edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" description = "A high-level API for reading and manipulating DICOM objects" diff --git a/object/src/lib.rs b/object/src/lib.rs index 31047d97..ca05ec18 100644 --- a/object/src/lib.rs +++ b/object/src/lib.rs @@ -772,7 +772,7 @@ mod tests { #[test] fn errors_not_too_large() { - assert_type_not_too_large::(56); + assert_type_not_too_large::(64); } #[test] diff --git a/parent/Cargo.toml b/parent/Cargo.toml index a0553a21..09e81462 100644 --- a/parent/Cargo.toml +++ b/parent/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho "] description = "A pure Rust implementation of the DICOM standard" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" readme = "README.md" diff --git a/parser/Cargo.toml b/parser/Cargo.toml index a1cd3a34..3c970222 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho "] description = "A middle-level parser and printer of DICOM data sets" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" categories = ["parser-implementations"] diff --git a/pixeldata/Cargo.toml b/pixeldata/Cargo.toml index 78a913e5..bb2978b9 100644 --- a/pixeldata/Cargo.toml +++ b/pixeldata/Cargo.toml @@ -3,6 +3,7 @@ name = "dicom-pixeldata" version = "0.7.1" authors = ["Eduardo Pinho ", "Peter Evers "] edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" description = "A high-level API for decoding DICOM objects into images and ndarrays" repository = "https://github.com/Enet4/dicom-rs" diff --git a/pixeldata/src/attribute.rs b/pixeldata/src/attribute.rs index 89443947..82521556 100644 --- a/pixeldata/src/attribute.rs +++ b/pixeldata/src/attribute.rs @@ -626,11 +626,12 @@ mod tests { #[test] fn errors_are_not_too_large() { + let max_size = 88; let size = std::mem::size_of::(); assert!( - size <= 80, - "GetAttributeError size is too large ({} > 80)", - size + size <= max_size, + "GetAttributeError size is too large ({} > {})", + size, max_size ); } diff --git a/toimage/Cargo.toml b/toimage/Cargo.toml index 05b5c94e..37022385 100644 --- a/toimage/Cargo.toml +++ b/toimage/Cargo.toml @@ -2,6 +2,7 @@ name = "dicom-toimage" version = "0.7.1" edition = "2018" +rust-version = "1.72.0" authors = ["Eduardo Pinho "] description = "A CLI tool for converting DICOM files into general purpose image files" license = "MIT OR Apache-2.0" diff --git a/transfer-syntax-registry/Cargo.toml b/transfer-syntax-registry/Cargo.toml index 0546d95b..f28f17db 100644 --- a/transfer-syntax-registry/Cargo.toml +++ b/transfer-syntax-registry/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho "] description = "A registry of DICOM transfer syntaxes" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" keywords = ["dicom"] diff --git a/ul/Cargo.toml b/ul/Cargo.toml index ab3607ad..d52eba9e 100644 --- a/ul/Cargo.toml +++ b/ul/Cargo.toml @@ -4,6 +4,7 @@ version = "0.7.1" authors = ["Eduardo Pinho ", "Paul Knopf "] description = "Types and methods for interacting with the DICOM Upper Layer Protocol" edition = "2018" +rust-version = "1.72.0" license = "MIT OR Apache-2.0" repository = "https://github.com/Enet4/dicom-rs" categories = ["network-programming"]