From 82fdcf527d4e52d53cac913a27557537894c193b Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 6 Jan 2024 15:06:05 +0000 Subject: [PATCH 1/6] Migrate snafu to 0.8 - admit extended size of AccessError due to the size of std backtrace --- Cargo.lock | 99 +++++++++++++++++--------------------------- core/Cargo.toml | 2 +- dump/Cargo.toml | 4 +- echoscu/Cargo.toml | 2 +- encoding/Cargo.toml | 2 +- findscu/Cargo.toml | 2 +- fromimage/Cargo.toml | 4 +- object/Cargo.toml | 3 +- object/src/lib.rs | 2 +- parent/Cargo.toml | 1 - parser/Cargo.toml | 2 +- pixeldata/Cargo.toml | 2 +- scpproxy/Cargo.toml | 2 +- storescp/Cargo.toml | 2 +- storescu/Cargo.toml | 2 +- toimage/Cargo.toml | 4 +- ul/Cargo.toml | 2 +- 17 files changed, 55 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ecd5633d..c87ee1616 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -101,21 +92,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.21.5" @@ -394,7 +370,7 @@ dependencies = [ "num-traits", "safe-transmute", "smallvec", - "snafu", + "snafu 0.8.0", ] [[package]] @@ -431,7 +407,7 @@ dependencies = [ "dicom-object", "dicom-transfer-syntax-registry", "owo-colors", - "snafu", + "snafu 0.8.0", "terminal_size", ] @@ -446,7 +422,7 @@ dependencies = [ "dicom-object", "dicom-transfer-syntax-registry", "dicom-ul", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -460,7 +436,7 @@ dependencies = [ "dicom-dictionary-std", "encoding", "inventory", - "snafu", + "snafu 0.8.0", ] [[package]] @@ -475,7 +451,7 @@ dependencies = [ "dicom-object", "dicom-transfer-syntax-registry", "dicom-ul", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -489,7 +465,7 @@ dependencies = [ "dicom-dictionary-std", "dicom-object", "image", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -522,7 +498,7 @@ dependencies = [ "dicom-transfer-syntax-registry", "itertools", "smallvec", - "snafu", + "snafu 0.8.0", "tempfile", "tracing", ] @@ -536,7 +512,7 @@ dependencies = [ "dicom-dictionary-std", "dicom-encoding", "smallvec", - "snafu", + "snafu 0.8.0", "tracing", ] @@ -558,7 +534,7 @@ dependencies = [ "num-traits", "rayon", "rstest", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -570,7 +546,7 @@ dependencies = [ "clap", "dicom-dictionary-std", "dicom-ul", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -586,7 +562,7 @@ dependencies = [ "dicom-object", "dicom-transfer-syntax-registry", "dicom-ul", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -604,7 +580,7 @@ dependencies = [ "dicom-transfer-syntax-registry", "dicom-ul", "indicatif", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", "walkdir", @@ -630,7 +606,7 @@ dependencies = [ "dicom-dictionary-std", "dicom-object", "dicom-pixeldata", - "snafu", + "snafu 0.8.0", "tracing", "tracing-subscriber", ] @@ -658,7 +634,7 @@ dependencies = [ "dicom-encoding", "dicom-transfer-syntax-registry", "matches", - "snafu", + "snafu 0.8.0", "tracing", ] @@ -949,7 +925,7 @@ dependencies = [ "cc", "cmake", "libc", - "snafu", + "snafu 0.7.5", "strum", "strum_macros", ] @@ -975,12 +951,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - [[package]] name = "glob" version = "0.3.1" @@ -1326,15 +1296,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" -[[package]] -name = "object" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -1569,12 +1530,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc_version" version = "0.4.0" @@ -1747,9 +1702,17 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" dependencies = [ - "backtrace", "doc-comment", - "snafu-derive", + "snafu-derive 0.7.5", +] + +[[package]] +name = "snafu" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d342c51730e54029130d7dc9fd735d28c4cd360f1368c01981d4f03ff207f096" +dependencies = [ + "snafu-derive 0.8.0", ] [[package]] @@ -1764,6 +1727,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "snafu-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "080c44971436b1af15d6f61ddd8b543995cf63ab8e677d46b00cc06f4ef267a0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "spin" version = "0.9.8" diff --git a/core/Cargo.toml b/core/Cargo.toml index 3c701678c..ceb94076b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,4 +15,4 @@ itertools = "0.12" num-traits = "0.2.12" safe-transmute = "0.11.0" smallvec = "1.6.1" -snafu = "0.7.3" +snafu = "0.8" diff --git a/dump/Cargo.toml b/dump/Cargo.toml index f39da569d..7f7b36de7 100644 --- a/dump/Cargo.toml +++ b/dump/Cargo.toml @@ -22,10 +22,10 @@ required-features = ["cli"] [features] default = ["cli", "sop-class"] sop-class = ["dicom-dictionary-std/sop-class"] -cli = ["clap", "dicom-transfer-syntax-registry/inventory-registry", "dicom-object/backtraces"] +cli = ["clap", "dicom-transfer-syntax-registry/inventory-registry"] [dependencies] -snafu = "0.7.3" +snafu = "0.8" clap = { version = "4.0.18", features = ["derive"], optional = true } dicom-core = { path = "../core", version = "0.6.3" } dicom-encoding = { path = "../encoding", version = "0.6.1" } diff --git a/echoscu/Cargo.toml b/echoscu/Cargo.toml index 76bbf2788..279718e82 100644 --- a/echoscu/Cargo.toml +++ b/echoscu/Cargo.toml @@ -18,6 +18,6 @@ dicom-dump = { version = "0.6.2", path = "../dump", default-features = false } dicom-object = { path = "../object/", version = "0.6.3" } dicom-transfer-syntax-registry = { path = "../transfer-syntax-registry/", version = "0.6.2", default-features = false } dicom-ul = { path = "../ul", version = "0.5.1" } -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.34" tracing-subscriber = "0.3.11" diff --git a/encoding/Cargo.toml b/encoding/Cargo.toml index 4de386487..d8e487107 100644 --- a/encoding/Cargo.toml +++ b/encoding/Cargo.toml @@ -16,7 +16,7 @@ dicom-dictionary-std = { path = "../dictionary-std", version = "0.6.1" } encoding = "0.2.33" byteordered = "0.6" inventory = { version = "0.3.2", optional = true } -snafu = "0.7.3" +snafu = "0.8" [features] default = [] diff --git a/findscu/Cargo.toml b/findscu/Cargo.toml index 5867002c5..c5287c70a 100644 --- a/findscu/Cargo.toml +++ b/findscu/Cargo.toml @@ -19,6 +19,6 @@ dicom-dictionary-std = { path = "../dictionary-std/", version = "0.6.1" } dicom-transfer-syntax-registry = { path = "../transfer-syntax-registry/", version = "0.6.2" } dicom-dump = { path = "../dump", default-features = false, version = "0.6.0" } clap = { version = "4.0.18", features = ["derive"] } -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.36" tracing-subscriber = "0.3.15" diff --git a/fromimage/Cargo.toml b/fromimage/Cargo.toml index 5b053ec12..e7a267a2c 100644 --- a/fromimage/Cargo.toml +++ b/fromimage/Cargo.toml @@ -11,14 +11,14 @@ keywords = ["cli", "dicom", "image", "image-conversion"] readme = "README.md" [features] -default = ['dicom-object/inventory-registry', 'dicom-object/backtraces'] +default = ['dicom-object/inventory-registry'] [dependencies] clap = { version = "4.0.18", features = ["derive"] } dicom-core = { path = "../core", version = "0.6.3" } dicom-dictionary-std = { path = "../dictionary-std/", version = "0.6.1" } dicom-object = { path = "../object/", version = "0.6.3" } -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.34" tracing-subscriber = "0.3.11" diff --git a/object/Cargo.toml b/object/Cargo.toml index b1c9a5a89..b1b3d59ee 100644 --- a/object/Cargo.toml +++ b/object/Cargo.toml @@ -12,7 +12,6 @@ readme = "README.md" [features] default = [] inventory-registry = ['dicom-encoding/inventory-registry', 'dicom-transfer-syntax-registry/inventory-registry'] -backtraces = ['snafu/backtraces'] [dependencies] dicom-core = { path = "../core", version = "0.6.3" } @@ -23,7 +22,7 @@ dicom-transfer-syntax-registry = { path = "../transfer-syntax-registry", version itertools = "0.12" byteordered = "0.6" smallvec = "1.6.1" -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.34" [dev-dependencies] diff --git a/object/src/lib.rs b/object/src/lib.rs index 22dd28917..97681da5c 100644 --- a/object/src/lib.rs +++ b/object/src/lib.rs @@ -717,7 +717,7 @@ mod tests { #[test] fn errors_not_too_large() { - assert_type_not_too_large::(48); + assert_type_not_too_large::(56); } #[test] diff --git a/parent/Cargo.toml b/parent/Cargo.toml index b81a5a35a..fa89fc04c 100644 --- a/parent/Cargo.toml +++ b/parent/Cargo.toml @@ -14,7 +14,6 @@ maintenance = { status = "actively-developed" } [features] default = ['inventory-registry', 'ul', 'pixeldata'] inventory-registry = ['dicom-encoding/inventory-registry', 'dicom-transfer-syntax-registry/inventory-registry'] -backtraces = ['dicom-object/backtraces'] ul = ['dicom-ul'] pixeldata = ['dicom-pixeldata'] image = ["pixeldata", "dicom-pixeldata/image"] diff --git a/parser/Cargo.toml b/parser/Cargo.toml index ba022804d..f88819bd7 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -16,5 +16,5 @@ dicom-encoding = { path = "../encoding", version = "0.6.1" } chrono = { version = "0.4.22", default-features = false, features = ["std"] } dicom-dictionary-std = { path = "../dictionary-std/", version = "0.6.1" } smallvec = "1.6.1" -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.34" diff --git a/pixeldata/Cargo.toml b/pixeldata/Cargo.toml index 0c02d2e8a..df7d835ab 100644 --- a/pixeldata/Cargo.toml +++ b/pixeldata/Cargo.toml @@ -21,7 +21,7 @@ dicom-core = { path = "../core", version = "0.6.3" } dicom-encoding = { path = "../encoding", version = "0.6.1" } dicom-transfer-syntax-registry = { path = "../transfer-syntax-registry", version = "0.6.2" } dicom-dictionary-std = { path = "../dictionary-std", version = "0.6.1" } -snafu = "0.7.3" +snafu = "0.8" byteorder = "1.4.3" gdcm-rs = { version = "0.5.0", optional = true } rayon = { version = "1.5.0", optional = true } diff --git a/scpproxy/Cargo.toml b/scpproxy/Cargo.toml index abdb244c4..8f0a12386 100644 --- a/scpproxy/Cargo.toml +++ b/scpproxy/Cargo.toml @@ -14,6 +14,6 @@ readme = "README.md" clap = { version = "4.0.18", features = ["cargo"] } dicom-ul = { path = "../ul/", version = "0.5.1" } dicom-dictionary-std = { path = "../dictionary-std/", version = "0.6.1" } -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.34" tracing-subscriber = "0.3.11" diff --git a/storescp/Cargo.toml b/storescp/Cargo.toml index 9e52393c7..5e12b016a 100644 --- a/storescp/Cargo.toml +++ b/storescp/Cargo.toml @@ -18,6 +18,6 @@ dicom-object = { path = '../object', version = "0.6.3" } dicom-encoding = { path = "../encoding/", version = "0.6.1" } dicom-dictionary-std = { path = "../dictionary-std/", version = "0.6.1" } dicom-transfer-syntax-registry = { path = "../transfer-syntax-registry/", version = "0.6.2" } -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.36" tracing-subscriber = "0.3.15" diff --git a/storescu/Cargo.toml b/storescu/Cargo.toml index 8912e8925..2c6ac0400 100644 --- a/storescu/Cargo.toml +++ b/storescu/Cargo.toml @@ -28,4 +28,4 @@ walkdir = "2.3.2" indicatif = "0.17.0" tracing = "0.1.34" tracing-subscriber = "0.3.11" -snafu = "0.7.3" +snafu = "0.8" diff --git a/toimage/Cargo.toml b/toimage/Cargo.toml index f5152e8b2..766518bbb 100644 --- a/toimage/Cargo.toml +++ b/toimage/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["cli", "dicom", "image", "image-conversion"] readme = "README.md" [features] -default = ['dicom-object/inventory-registry', 'dicom-object/backtraces', 'dicom-pixeldata/native'] +default = ['dicom-object/inventory-registry', 'dicom-pixeldata/native'] [dependencies] clap = { version = "4.0.18", features = ["derive"] } @@ -19,6 +19,6 @@ dicom-core = { version = "0.6.3", path = "../core" } dicom-dictionary-std = { version = "0.6.1", path = "../dictionary-std" } dicom-object = { path = "../object/", version = "0.6.3" } dicom-pixeldata = { path = "../pixeldata/", version = "0.2.2", default-features = false, features = ["image", "rayon"] } -snafu = { version = "0.7.3", features = ["rust_1_61"] } +snafu = "0.8" tracing = "0.1.34" tracing-subscriber = "0.3.11" diff --git a/ul/Cargo.toml b/ul/Cargo.toml index 37c816f20..a0fbe3d38 100644 --- a/ul/Cargo.toml +++ b/ul/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" byteordered = "0.6" dicom-encoding = { path = "../encoding/", version = "0.6.1" } dicom-transfer-syntax-registry = { path = "../transfer-syntax-registry/", version = "0.6.2", default-features = false } -snafu = "0.7.3" +snafu = "0.8" tracing = "0.1.34" [dev-dependencies] From 484908f17b3bc9a1d6100dc3c03dc93679dd077d Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 6 Jan 2024 16:23:27 +0000 Subject: [PATCH 2/6] Update CI - remove backtraces feature from Windows build --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cf2d831c0..d04df7175 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -46,7 +46,7 @@ jobs: with: toolchain: stable cache: true - - run: cargo build + - run: cargo build --features=cli,inventory-registry,sop-class check_macos: name: Check (macOS) From 20905b34e3489a3a5fe955decda7cbcf17e3123d Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 6 Jan 2024 16:25:51 +0000 Subject: [PATCH 3/6] [pixeldata] Relax GetAttributeError size to 80 bytes --- pixeldata/src/attribute.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pixeldata/src/attribute.rs b/pixeldata/src/attribute.rs index e1ed3025b..ef3946b0d 100644 --- a/pixeldata/src/attribute.rs +++ b/pixeldata/src/attribute.rs @@ -502,8 +502,8 @@ mod tests { fn errors_are_not_too_large() { let size = std::mem::size_of::(); assert!( - size <= 64, - "GetAttributeError size is too large ({} > 64)", + size <= 80, + "GetAttributeError size is too large ({} > 80)", size ); } From bd14a24ffe9eb16708395b1b90a00a9d9d4bbc1d Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sun, 10 Mar 2024 11:47:57 +0000 Subject: [PATCH 4/6] [core] Box InvalidValueReadError in ConvertValueError cause to reduce inline value size --- core/src/value/primitive.rs | 245 ++++++++++++++++++------------------ 1 file changed, 123 insertions(+), 122 deletions(-) diff --git a/core/src/value/primitive.rs b/core/src/value/primitive.rs index 723101fd8..4a6292501 100644 --- a/core/src/value/primitive.rs +++ b/core/src/value/primitive.rs @@ -154,7 +154,7 @@ pub struct ConvertValueError { /// The reason why the conversion was unsuccessful, /// or none if a conversion from the given original representation /// is not possible - pub cause: Option, + pub cause: Option>, } impl Display for ConvertValueError { @@ -915,7 +915,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "integer", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) if !s.is_empty() => s[0] @@ -925,7 +925,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "integer", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) if !bytes.is_empty() => { T::from(bytes[0]).ok_or_else(|| ConvertValueError { @@ -935,7 +935,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: bytes[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -947,7 +947,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -959,7 +959,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -971,7 +971,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -983,7 +983,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -995,7 +995,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1007,7 +1007,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1075,7 +1075,7 @@ impl PrimitiveValue { ConvertValueError { requested: "integer", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), } })?; Ok(vec![out]) @@ -1087,7 +1087,7 @@ impl PrimitiveValue { ConvertValueError { requested: "integer", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), } }) }) @@ -1103,7 +1103,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1118,7 +1118,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1133,7 +1133,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1148,7 +1148,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1163,7 +1163,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1178,7 +1178,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1193,7 +1193,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1248,7 +1248,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float32", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) if !s.is_empty() => s[0] @@ -1258,7 +1258,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float32", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) if !bytes.is_empty() => { NumCast::from(bytes[0]).ok_or_else(|| ConvertValueError { @@ -1268,7 +1268,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: bytes[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1280,7 +1280,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1292,7 +1292,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1304,7 +1304,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1316,7 +1316,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1328,7 +1328,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1340,7 +1340,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1353,7 +1353,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1410,7 +1410,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float32", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), })?; Ok(vec![out]) } @@ -1423,7 +1423,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float32", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) }) .collect::, _>>(), @@ -1437,7 +1437,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1452,7 +1452,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1467,7 +1467,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1482,7 +1482,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1497,7 +1497,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1512,7 +1512,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1527,7 +1527,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1543,7 +1543,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1598,7 +1598,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float64", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) if !s.is_empty() => s[0] @@ -1608,7 +1608,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float64", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) if !bytes.is_empty() => { NumCast::from(bytes[0]).ok_or_else(|| ConvertValueError { @@ -1618,7 +1618,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: bytes[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1630,7 +1630,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1642,7 +1642,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1654,7 +1654,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1666,7 +1666,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1678,7 +1678,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1690,7 +1690,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1702,7 +1702,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build(), + .build().into(), ), }) } @@ -1759,7 +1759,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float64", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), })?; Ok(vec![out]) } @@ -1772,7 +1772,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "float64", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) }) .collect::, _>>(), @@ -1786,7 +1786,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1801,7 +1801,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1816,7 +1816,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1831,7 +1831,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1846,7 +1846,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1861,7 +1861,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1876,7 +1876,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1891,7 +1891,7 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build(), + .build().into(), ), }) }) @@ -1964,14 +1964,14 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::deserialize::parse_date(s.as_bytes()) .context(ParseDateSnafu) .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => { super::deserialize::parse_date(s.first().map(|s| s.as_bytes()).unwrap_or(&[])) @@ -1979,7 +1979,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::U8(bytes) => super::deserialize::parse_date(bytes) @@ -1987,7 +1987,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "NaiveDate", @@ -2056,7 +2056,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::deserialize::parse_date(s.trim_end().as_bytes()) .map(|date| vec![date]) @@ -2064,7 +2064,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => s .into_iter() @@ -2074,7 +2074,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => trim_last_whitespace(bytes) .split(|c| *c == b'\\') @@ -2084,7 +2084,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "NaiveDate", @@ -2161,7 +2161,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => super::deserialize::parse_date_partial( s.first().map(|s| s.as_bytes()).unwrap_or(&[]), @@ -2171,7 +2171,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => super::deserialize::parse_date_partial(bytes) .map(|(date, _)| date) @@ -2179,7 +2179,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "DicomDate", @@ -2222,7 +2222,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) => s @@ -2236,7 +2236,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => trim_last_whitespace(bytes) .split(|c| *c == b'\\') @@ -2246,7 +2246,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDate", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "DicomDate", @@ -2305,7 +2305,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::deserialize::parse_time(s.trim_end().as_bytes()) .map(|(date, _rest)| date) @@ -2313,7 +2313,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => super::deserialize::parse_time( s.first().map(|s| s.trim_end().as_bytes()).unwrap_or(&[]), @@ -2323,7 +2323,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::deserialize::parse_time(trim_last_whitespace(bytes)) @@ -2332,7 +2332,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -2402,7 +2402,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::deserialize::parse_time(s.trim_end().as_bytes()) .map(|(date, _rest)| vec![date]) @@ -2410,7 +2410,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => s .into_iter() @@ -2423,7 +2423,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => trim_last_whitespace(bytes) .split(|c| *c == b'\\') @@ -2433,7 +2433,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "NaiveTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "NaiveTime", @@ -2526,7 +2526,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) => super::deserialize::parse_time_partial( @@ -2537,7 +2537,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::deserialize::parse_time_partial(trim_last_whitespace(bytes)) @@ -2546,7 +2546,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -2606,7 +2606,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) => s @@ -2620,7 +2620,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => trim_last_whitespace(bytes) .split(|c| *c == b'\\') @@ -2630,7 +2630,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "DicomTime", @@ -2731,7 +2731,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDateTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) => super::deserialize::parse_datetime_partial( @@ -2741,7 +2741,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDateTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::deserialize::parse_datetime_partial(trim_last_whitespace(bytes)) @@ -2749,7 +2749,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDateTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -2772,7 +2772,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDateTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) => s @@ -2783,7 +2783,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDateTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => trim_last_whitespace(bytes) .split(|c| *c == b'\\') @@ -2793,7 +2793,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DicomDateTime", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), _ => Err(ConvertValueError { requested: "DicomDateTime", @@ -2847,14 +2847,14 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::range::parse_date_range(s.trim_end().as_bytes()) .context(ParseDateRangeSnafu) .map_err(|err| ConvertValueError { requested: "DateRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => super::range::parse_date_range( s.first().map(|s| s.trim_end().as_bytes()).unwrap_or(&[]), @@ -2863,7 +2863,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::range::parse_date_range(trim_last_whitespace(bytes)) @@ -2871,7 +2871,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -2930,14 +2930,14 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "TimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::range::parse_time_range(s.trim_end().as_bytes()) .context(ParseTimeRangeSnafu) .map_err(|err| ConvertValueError { requested: "TimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => super::range::parse_time_range( s.first().map(|s| s.trim_end().as_bytes()).unwrap_or(&[]), @@ -2946,7 +2946,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "TimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::range::parse_time_range(trim_last_whitespace(bytes)) @@ -2954,7 +2954,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "TimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -3044,14 +3044,14 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => super::range::parse_datetime_range(s.trim_end().as_bytes()) .context(ParseDateTimeRangeSnafu) .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Strs(s) => super::range::parse_datetime_range( s.first().map(|s| s.trim_end().as_bytes()).unwrap_or(&[]), @@ -3060,7 +3060,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::range::parse_datetime_range(trim_last_whitespace(bytes)) @@ -3068,7 +3068,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -3148,7 +3148,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::Str(s) => { super::range::parse_datetime_range_custom::(s.trim_end().as_bytes()) @@ -3156,7 +3156,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } PrimitiveValue::Strs(s) => super::range::parse_datetime_range_custom::( @@ -3166,7 +3166,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }), PrimitiveValue::U8(bytes) => { super::range::parse_datetime_range_custom::(trim_last_whitespace(bytes)) @@ -3174,7 +3174,7 @@ impl PrimitiveValue { .map_err(|err| ConvertValueError { requested: "DateTimeRange", original: self.value_type(), - cause: Some(err), + cause: Some(Box::from(err)), }) } _ => Err(ConvertValueError { @@ -4479,8 +4479,8 @@ mod tests { requested: _, original: ValueType::Strs, // would try to parse as an integer and fail - cause: Some(InvalidValueReadError::ParseInteger { .. }), - }) + cause: Some(cause), + }) if matches!(&*cause, InvalidValueReadError::ParseInteger { .. }) )); } @@ -4520,12 +4520,13 @@ mod tests { Err(ConvertValueError { original: ValueType::I32, // the cast from -1_i32 to u32 would fail - cause: Some(InvalidValueReadError::NarrowConvert { - value: x, - .. - }), + cause: Some(cause), .. - }) if &x == "-1" + }) if matches!(&*cause, + InvalidValueReadError::NarrowConvert { + value: x, + .. + } if x == "-1") )); // not even from strings @@ -4534,9 +4535,9 @@ mod tests { Err(ConvertValueError { original: ValueType::Strs, // the conversion from "-1" to u32 would fail - cause: Some(InvalidValueReadError::ParseInteger { .. }), + cause: Some(cause), .. - }) + }) if matches!(&*cause, InvalidValueReadError::ParseInteger { .. }) )); // does not admit strings which are not numbers @@ -4546,8 +4547,8 @@ mod tests { requested: _, original: ValueType::Strs, // would try to parse as an integer and fail - cause: Some(InvalidValueReadError::ParseInteger { .. }), - }) + cause: Some(cause), + }) if matches!(&*cause, InvalidValueReadError::ParseInteger { .. }) )); } @@ -4581,8 +4582,8 @@ mod tests { requested: _, original: ValueType::Strs, // would try to parse as a float and fail - cause: Some(InvalidValueReadError::ParseFloat { .. }), - }) + cause: Some(cause), + }) if matches!(&*cause, InvalidValueReadError::ParseFloat { .. }) )); } From ccba8de6ac031c140ca8d651279e657c7abb8746 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sun, 10 Mar 2024 11:48:18 +0000 Subject: [PATCH 5/6] [core] Format primitive.rs --- core/src/value/primitive.rs | 138 ++++++++++++++++++++++++------------ 1 file changed, 92 insertions(+), 46 deletions(-) diff --git a/core/src/value/primitive.rs b/core/src/value/primitive.rs index 4a6292501..1db626c16 100644 --- a/core/src/value/primitive.rs +++ b/core/src/value/primitive.rs @@ -935,7 +935,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: bytes[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -947,7 +948,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -959,7 +961,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -971,7 +974,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -983,7 +987,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -995,7 +1000,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1007,7 +1013,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1103,7 +1110,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1118,7 +1126,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1133,7 +1142,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1148,7 +1158,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1163,7 +1174,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1178,7 +1190,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1193,7 +1206,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1268,7 +1282,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: bytes[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1280,7 +1295,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1292,7 +1308,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1304,7 +1321,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1316,7 +1334,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1328,7 +1347,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1340,7 +1360,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1353,7 +1374,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1437,7 +1459,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1452,7 +1475,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1467,7 +1491,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1482,7 +1507,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1497,7 +1523,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1512,7 +1539,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1527,7 +1555,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1543,7 +1572,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1618,7 +1648,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: bytes[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1630,7 +1661,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1642,7 +1674,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1654,7 +1687,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1666,7 +1700,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1678,7 +1713,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1690,7 +1726,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1702,7 +1739,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: s[0].to_string(), } - .build().into(), + .build() + .into(), ), }) } @@ -1786,7 +1824,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1801,7 +1840,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1816,7 +1856,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1831,7 +1872,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1846,7 +1888,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1861,7 +1904,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1876,7 +1920,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) @@ -1891,7 +1936,8 @@ impl PrimitiveValue { NarrowConvertSnafu { value: v.to_string(), } - .build().into(), + .build() + .into(), ), }) }) From 5418cfc4541e7208e2b6fed8c6ef984227412e39 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sun, 10 Mar 2024 11:49:00 +0000 Subject: [PATCH 6/6] [storescu] Box WriteError in Error::CreateCommand to reduce inline value size --- storescu/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storescu/src/main.rs b/storescu/src/main.rs index ca29e91df..b80759043 100644 --- a/storescu/src/main.rs +++ b/storescu/src/main.rs @@ -81,7 +81,7 @@ enum Error { }, /// Could not construct DICOM command - CreateCommand { source: dicom_object::WriteError }, + CreateCommand { source: Box }, /// Unsupported file transfer syntax {uid} UnsupportedFileTransferSyntax { uid: std::borrow::Cow<'static, str> }, @@ -262,6 +262,7 @@ fn run() -> Result<(), Error> { &mut cmd_data, &dicom_transfer_syntax_registry::entries::IMPLICIT_VR_LITTLE_ENDIAN.erased(), ) + .map_err(Box::from) .context(CreateCommandSnafu)?; let mut object_data = Vec::with_capacity(2048);