From e266b64c55295cc3084b832b48c8bd4f73947dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=AD=90=EF=B8=8FNINIKA=E2=AD=90=EF=B8=8F?= Date: Tue, 12 Nov 2024 12:21:15 +0300 Subject: [PATCH] feat(macros): Implement a derive-where-like macro for serde (#5220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ⭐️NINIKA⭐️ --- Cargo.lock | 710 +++++++++++------------ crates/iroha_derive/Cargo.toml | 4 + crates/iroha_derive/src/from_variant.rs | 302 ++++++++++ crates/iroha_derive/src/lib.rs | 348 ++--------- crates/iroha_derive/src/serde_where.rs | 59 ++ crates/iroha_derive/tests/serde_where.rs | 12 + crates/iroha_primitives/src/small.rs | 11 +- 7 files changed, 765 insertions(+), 681 deletions(-) create mode 100644 crates/iroha_derive/src/from_variant.rs create mode 100644 crates/iroha_derive/src/serde_where.rs create mode 100644 crates/iroha_derive/tests/serde_where.rs diff --git a/Cargo.lock b/Cargo.lock index f273833c325..4940c0f920d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,9 +145,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" @@ -295,9 +295,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.9" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" +checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" @@ -319,9 +319,9 @@ checksum = "0c24e9d990669fbd16806bff449e4ac644fd9b1fca014760087732fe4102f131" [[package]] name = "async-stream" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", @@ -330,24 +330,24 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -373,9 +373,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -400,20 +400,20 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 0.1.2", - "tower 0.4.13", + "tower", "tower-layer", "tower-service", ] [[package]] name = "axum" -version = "0.7.7" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", - "axum-core 0.4.5", - "base64 0.22.1", + "axum-core 0.4.3", + "base64 0.21.7", "bytes", "futures-util", "http 1.1.0", @@ -436,8 +436,8 @@ dependencies = [ "sha1", "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite 0.24.0", - "tower 0.5.1", + "tokio-tungstenite", + "tower", "tower-layer", "tower-service", ] @@ -461,9 +461,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.5" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", @@ -474,7 +474,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -581,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.7", "serde", ] @@ -605,9 +605,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "camino" @@ -649,9 +649,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.24" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" dependencies = [ "jobserver", "libc", @@ -749,9 +749,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.19" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", "clap_derive", @@ -759,9 +759,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.19" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -771,14 +771,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -947,18 +947,18 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.4.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96e58d342ad113c2b878f16d5d034c03be492ae460cdbc02b7f0f2284d310c7d" +checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" dependencies = [ "cfg-if", ] [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -1238,14 +1238,14 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "cxx" -version = "1.0.128" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ccead7d199d584d139148b04b4a368d1ec7556a1d9ea2548febb1b9d49f9a4" +checksum = "3c4eae4b7fc8dcb0032eb3b1beee46b38d371cdeaf2d0c64b9944f6f69ad7755" dependencies = [ "cc", "cxxbridge-flags", @@ -1255,9 +1255,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.128" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77953e99f01508f89f55c494bfa867171ef3a6c8cea03d26975368f2121a5c1" +checksum = "6c822bf7fb755d97328d6c337120b6f843678178751cba33c9da25cf522272e0" dependencies = [ "cc", "codespan-reporting", @@ -1265,24 +1265,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "cxxbridge-flags" -version = "1.0.128" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65777e06cc48f0cb0152024c77d6cf9e4bdb4408e7b48bea993d42fa0f5b02b6" +checksum = "719d6197dc016c88744aff3c0d0340a01ecce12e8939fc282e7c8f583ee64bc6" [[package]] name = "cxxbridge-macro" -version = "1.0.128" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98532a60dedaebc4848cb2cba5023337cc9ea3af16a5b062633fabfd9f18fb60" +checksum = "35de3b547387863c8f82013c4f79f1c2162edee956383e4089e1d04c18c4f16c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -1306,7 +1306,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -1317,7 +1317,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -1393,7 +1393,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -1404,7 +1404,7 @@ checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -1448,7 +1448,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -1642,9 +1642,9 @@ checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "ff" @@ -1664,9 +1664,9 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "filetime" -version = "0.2.25" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" dependencies = [ "cfg-if", "libc", @@ -1694,9 +1694,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "9c0596c1eac1f9e04ed902702e9878208b336edc9d6fddc8a48387349bab3666" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -1750,9 +1750,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -1765,9 +1765,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -1775,15 +1775,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -1792,38 +1792,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -1883,14 +1883,14 @@ dependencies = [ [[package]] name = "getset" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f636605b743120a8d32ed92fc27b6cde1a769f8f936c065151eb66f88ded513c" +checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" dependencies = [ - "proc-macro-error2", + "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.79", + "syn 1.0.109", ] [[package]] @@ -1900,7 +1900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" dependencies = [ "fallible-iterator", - "indexmap 2.6.0", + "indexmap 2.4.0", "stable_deref_trait", ] @@ -1957,7 +1957,7 @@ dependencies = [ "gix-utils", "itoa", "thiserror", - "winnow", + "winnow 0.6.18", ] [[package]] @@ -2010,7 +2010,7 @@ dependencies = [ "smallvec", "thiserror", "unicode-bom", - "winnow", + "winnow 0.6.18", ] [[package]] @@ -2176,7 +2176,7 @@ checksum = "999ce923619f88194171a67fb3e6d613653b8d4d6078b529b15a765da0edcc17" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -2195,7 +2195,7 @@ dependencies = [ "itoa", "smallvec", "thiserror", - "winnow", + "winnow 0.6.18", ] [[package]] @@ -2238,9 +2238,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.10.11" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebfc4febd088abdcbc9f1246896e57e37b7a34f6909840045a1767c6dafac7af" +checksum = "38d5b8722112fa2fa87135298780bc833b0e9f6c56cc82795d209804b3a03484" dependencies = [ "bstr", "gix-trace", @@ -2279,7 +2279,7 @@ dependencies = [ "gix-validate", "memmap2", "thiserror", - "winnow", + "winnow 0.6.18", ] [[package]] @@ -2356,9 +2356,9 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.10" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cae0e8661c3ff92688ce1c8b8058b3efb312aba9492bbe93661a21705ab431b" +checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e" [[package]] name = "gix-traverse" @@ -2440,7 +2440,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.6.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -2459,7 +2459,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.6.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -2502,12 +2502,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashbrown" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" - [[package]] name = "hdrhistogram" version = "7.5.4" @@ -2645,9 +2639,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.5" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -2716,7 +2710,7 @@ dependencies = [ "http 1.1.0", "hyper 1.4.1", "hyper-util", - "rustls 0.23.13", + "rustls 0.23.12", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -2753,9 +2747,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.9" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", @@ -2766,15 +2760,16 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", + "tower", "tower-service", "tracing", ] [[package]] name = "iana-time-zone" -version = "0.1.61" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2851,12 +2846,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.14.5", "serde", ] @@ -2942,10 +2937,10 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "tokio-tungstenite 0.21.0", + "tokio-tungstenite", "toml", "trybuild", - "tungstenite 0.21.0", + "tungstenite", "url", ] @@ -3045,7 +3040,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.79", + "syn 2.0.75", "trybuild", ] @@ -3062,7 +3057,7 @@ dependencies = [ "eyre", "futures", "hex", - "indexmap 2.6.0", + "indexmap 2.4.0", "iroha_config", "iroha_crypto", "iroha_data_model", @@ -3174,7 +3169,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.79", + "syn 2.0.75", "trybuild", ] @@ -3185,10 +3180,12 @@ dependencies = [ "darling", "impls", "iroha_macro", + "iroha_macro_utils", "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "serde", + "syn 2.0.75", "trybuild", ] @@ -3224,7 +3221,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3236,7 +3233,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3262,7 +3259,7 @@ dependencies = [ "quote", "rustc-hash", "strum 0.25.0", - "syn 2.0.79", + "syn 2.0.75", "trybuild", ] @@ -3290,7 +3287,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3364,7 +3361,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3447,7 +3444,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3471,7 +3468,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", "trybuild", ] @@ -3511,7 +3508,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3569,7 +3566,7 @@ dependencies = [ "streaming-stats", "tokio", "tokio-stream", - "tokio-tungstenite 0.21.0", + "tokio-tungstenite", "url", "vergen", ] @@ -3582,7 +3579,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", "trybuild", ] @@ -3633,7 +3630,7 @@ name = "iroha_torii" version = "2.0.0-rc.1.0" dependencies = [ "async-trait", - "axum 0.7.7", + "axum 0.7.5", "displaydoc", "error-stack", "eyre", @@ -3660,7 +3657,7 @@ dependencies = [ "thiserror", "tokio", "tower-http", - "tungstenite 0.21.0", + "tungstenite", ] [[package]] @@ -3688,7 +3685,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3718,7 +3715,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.79", + "syn 2.0.75", "trybuild", ] @@ -3755,7 +3752,7 @@ dependencies = [ "manyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -3898,9 +3895,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.4" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -3942,9 +3939,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libflate" @@ -3989,9 +3986,9 @@ dependencies = [ [[package]] name = "libsodium-sys-stable" -version = "1.21.2" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42631d334de875c636a1aae7adb515653ac2e771e5a2ce74b1053f5a4412df3a" +checksum = "5fd1882b85f01cdd4021c0664fd897710a04c5d01b593a5a70e1b0baa999c1f8" dependencies = [ "cc", "libc", @@ -4069,7 +4066,7 @@ dependencies = [ "manyhow-macros", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -4115,9 +4112,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -4145,9 +4142,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "minisign-verify" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a05b5d0594e0cb1ad8cee3373018d2b84e25905dc75b2468114cc9a8e86cfc20" +checksum = "933dca44d65cdd53b355d0b73d380a2ff5da71f87f036053188bf1eab6a19881" [[package]] name = "miniz_oxide" @@ -4356,24 +4353,21 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "crc32fast", "hashbrown 0.14.5", - "indexmap 2.6.0", + "indexmap 2.4.0", "memchr", ] [[package]] name = "once_cell" -version = "1.20.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -4410,7 +4404,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -4421,9 +4415,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.2+3.3.2" +version = "300.3.1+3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b" +checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" dependencies = [ "cc", ] @@ -4553,9 +4547,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.13" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" +checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" dependencies = [ "memchr", "thiserror", @@ -4564,9 +4558,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.13" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" +checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" dependencies = [ "pest", "pest_generator", @@ -4574,22 +4568,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.13" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" +checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "pest_meta" -version = "2.7.13" +version = "2.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" +checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" dependencies = [ "once_cell", "pest", @@ -4603,7 +4597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.6.0", + "indexmap 2.4.0", ] [[package]] @@ -4623,7 +4617,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -4650,15 +4644,15 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" -version = "0.3.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -4669,15 +4663,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" [[package]] name = "plotters-svg" -version = "0.3.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" dependencies = [ "plotters-backend", ] @@ -4693,12 +4687,6 @@ dependencies = [ "universal-hash", ] -[[package]] -name = "portable-atomic" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" - [[package]] name = "postcard" version = "1.0.10" @@ -4763,38 +4751,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "788992637e9c73f809f7bdc647572785efb06cb7c860105a4e55e9c7d6935d39" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit", + "toml_edit 0.21.1", ] [[package]] -name = "proc-macro-error-attr2" -version = "2.0.0" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ + "proc-macro-error-attr", "proc-macro2", "quote", + "syn 1.0.109", + "version_check", ] [[package]] -name = "proc-macro-error2" -version = "2.0.1" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.79", + "version_check", ] [[package]] @@ -4857,7 +4847,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -4896,9 +4886,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.23" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" dependencies = [ "cc", ] @@ -4970,9 +4960,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags 2.6.0", ] @@ -5003,14 +4993,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", - "regex-syntax 0.8.5", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", ] [[package]] @@ -5024,13 +5014,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax 0.8.4", ] [[package]] @@ -5041,15 +5031,15 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", @@ -5144,18 +5134,18 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ "semver", ] [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.6.0", "errno", @@ -5180,9 +5170,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "rustls-pki-types", @@ -5193,9 +5183,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -5206,24 +5196,25 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.2.0" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ + "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", "rustls-pki-types", @@ -5253,20 +5244,20 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.0" +version = "2.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836f1e0f4963ef5288b539b643b35e043e76a32d0f4e47e67febf69576527f50" +checksum = "aeb7ac86243095b70a7920639507b71d51a63390d1ba26c4f60a552fbb914a37" dependencies = [ "sdd", ] [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -5283,9 +5274,9 @@ checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sdd" -version = "3.0.3" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a7b59a5d9b0099720b417b6325d91a52cbf5b3dcb5041d864be53eefa58abc" +checksum = "0495e4577c672de8254beb68d01a9b62d0e8a13c099edecdbedccce3223cd29f" [[package]] name = "sec1" @@ -5303,9 +5294,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.29.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" dependencies = [ "rand", "secp256k1-sys", @@ -5314,9 +5305,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" dependencies = [ "cc", ] @@ -5336,9 +5327,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -5355,29 +5346,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "itoa", "memchr", @@ -5397,9 +5388,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.8" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -5418,15 +5409,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.10.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9720086b3357bcb44fce40117d769a4d068c70ecfa190850a980a71755f66fcc" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.6.0", + "indexmap 2.4.0", "serde", "serde_derive", "serde_json", @@ -5436,14 +5427,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.10.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f1abbfe725f27678f4663bcacb75a83e829fd464c25d78dd038a3a29e307cec" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -5452,7 +5443,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -5481,7 +5472,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -5745,7 +5736,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -5775,9 +5766,9 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "12.12.0" +version = "12.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366f1b4c6baf6cfefc234bbd4899535fca0b06c74443039a73f6dfb2fad88d77" +checksum = "16629323a4ec5268ad23a575110a724ad4544aae623451de600c747bf87b36cf" dependencies = [ "debugid", "memmap2", @@ -5787,9 +5778,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.12.0" +version = "12.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aba05ba5b9962ea5617baf556293720a8b2d0a282aa14ee4bf10e22efc7da8c8" +checksum = "48c043a45f08f41187414592b3ceb53fb0687da57209cc77401767fb69d5b596" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -5809,9 +5800,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ "proc-macro2", "quote", @@ -5862,9 +5853,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.42" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" +checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" dependencies = [ "filetime", "libc", @@ -5879,9 +5870,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.13.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", @@ -5901,22 +5892,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -5999,9 +5990,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -6033,7 +6024,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -6063,16 +6054,16 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.13", + "rustls 0.23.12", "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -6095,27 +6086,15 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.25.0", - "tungstenite 0.21.0", + "tungstenite", "webpki-roots", ] -[[package]] -name = "tokio-tungstenite" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.24.0", -] - [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -6135,7 +6114,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.22.20", ] [[package]] @@ -6149,15 +6128,26 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.6.0", + "indexmap 2.4.0", + "toml_datetime", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.18", ] [[package]] @@ -6181,7 +6171,7 @@ dependencies = [ "prost", "tokio", "tokio-stream", - "tower 0.4.13", + "tower", "tower-layer", "tower-service", "tracing", @@ -6207,21 +6197,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper 0.1.2", - "tokio", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-http" version = "0.5.2" @@ -6272,7 +6247,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -6378,24 +6353,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "tungstenite" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand", - "sha1", - "thiserror", - "utf-8", -] - [[package]] name = "typeid" version = "1.0.2" @@ -6410,15 +6367,15 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "unicode-bidi" -version = "0.3.17" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-bom" @@ -6428,36 +6385,36 @@ checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.24" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.12.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.14" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" -version = "0.2.6" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" [[package]] name = "unique_port" @@ -6639,7 +6596,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", "wasm-bindgen-shared", ] @@ -6673,7 +6630,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6695,9 +6652,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.218.0" +version = "0.216.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22b896fa8ceb71091ace9bcb81e853f54043183a1c9667cf93422c40252ffa0a" +checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88" dependencies = [ "leb128", ] @@ -6751,7 +6708,7 @@ dependencies = [ "ahash", "bitflags 2.6.0", "hashbrown 0.14.5", - "indexmap 2.6.0", + "indexmap 2.4.0", "semver", "serde", ] @@ -6782,7 +6739,7 @@ dependencies = [ "fxprof-processed-profile", "gimli", "hashbrown 0.14.5", - "indexmap 2.6.0", + "indexmap 2.4.0", "ittapi", "libc", "libm", @@ -6790,7 +6747,7 @@ dependencies = [ "mach2", "memfd", "memoffset", - "object 0.36.4", + "object 0.36.3", "once_cell", "paste", "postcard", @@ -6860,7 +6817,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -6888,7 +6845,7 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "object 0.36.4", + "object 0.36.3", "target-lexicon", "thiserror", "wasmparser", @@ -6906,9 +6863,9 @@ dependencies = [ "cpp_demangle", "cranelift-entity", "gimli", - "indexmap 2.6.0", + "indexmap 2.4.0", "log", - "object 0.36.4", + "object 0.36.3", "postcard", "rustc-demangle", "serde", @@ -6942,7 +6899,7 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bc54198c6720f098210a85efb3ba8c078d1de4d373cdb6778850a66ae088d11" dependencies = [ - "object 0.36.4", + "object 0.36.3", "once_cell", "rustix", "wasmtime-versioned-export-macros", @@ -6987,7 +6944,7 @@ checksum = "de5a9bc4f44ceeb168e9e8e3be4e0b4beb9095b468479663a9e24c667e36826f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -6999,7 +6956,7 @@ dependencies = [ "anyhow", "cranelift-codegen", "gimli", - "object 0.36.4", + "object 0.36.3", "target-lexicon", "wasmparser", "wasmtime-cranelift", @@ -7015,28 +6972,28 @@ checksum = "70dc077306b38288262e5ba01d4b21532a6987416cdc0aedf04bb06c22a68fdc" dependencies = [ "anyhow", "heck 0.4.1", - "indexmap 2.6.0", + "indexmap 2.4.0", "wit-parser", ] [[package]] name = "wast" -version = "218.0.0" +version = "216.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a53cd1f0fa505df97557e36a58bddb8296e2fcdcd089529545ebfdb18a1b9d7" +checksum = "f7eb1f2eecd913fdde0dc6c3439d0f24530a98ac6db6cb3d14d92a5328554a08" dependencies = [ "bumpalo", "leb128", "memchr", "unicode-width", - "wasm-encoder 0.218.0", + "wasm-encoder 0.216.0", ] [[package]] name = "wat" -version = "1.218.0" +version = "1.216.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f87f8e14e776762e07927c27c2054d2cf678aab9aae2d431a79b3e31e4dd391" +checksum = "ac0409090fb5154f95fb5ba3235675fd9e579e731524d63b6a2f653e1280c82a" dependencies = [ "wast", ] @@ -7063,9 +7020,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] @@ -7319,9 +7276,18 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] @@ -7340,7 +7306,7 @@ checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" dependencies = [ "anyhow", "id-arena", - "indexmap 2.6.0", + "indexmap 2.4.0", "log", "semver", "serde", @@ -7398,7 +7364,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -7418,7 +7384,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.75", ] [[package]] @@ -7432,7 +7398,7 @@ dependencies = [ "crossbeam-utils", "displaydoc", "flate2", - "indexmap 2.6.0", + "indexmap 2.4.0", "memchr", "thiserror", "zopfli", diff --git a/crates/iroha_derive/Cargo.toml b/crates/iroha_derive/Cargo.toml index dc9e23598d2..4ccf44a799e 100644 --- a/crates/iroha_derive/Cargo.toml +++ b/crates/iroha_derive/Cargo.toml @@ -14,6 +14,8 @@ workspace = true proc-macro = true [dependencies] +iroha_macro_utils = { path = "../iroha_macro_utils" } + syn = { workspace = true, features = ["default", "full"] } quote = { workspace = true } proc-macro2 = { workspace = true } @@ -25,3 +27,5 @@ iroha_macro = { workspace = true } trybuild = { workspace = true } impls = { workspace = true } + +serde = { workspace = true, features = ["derive"] } diff --git a/crates/iroha_derive/src/from_variant.rs b/crates/iroha_derive/src/from_variant.rs new file mode 100644 index 00000000000..4992f1e9e61 --- /dev/null +++ b/crates/iroha_derive/src/from_variant.rs @@ -0,0 +1,302 @@ +use darling::{util::SpannedValue, FromDeriveInput}; +use proc_macro2::{Span, TokenStream}; +use quote::{quote, quote_spanned, ToTokens as _}; +use syn::{spanned::Spanned as _, Token}; + +/// Attribute for skipping from attribute +const SKIP_FROM_ATTR: &str = "skip_from"; +const SKIP_TRY_FROM_ATTR: &str = "skip_try_from"; +/// Attribute to skip inner container optimization. Useful for trait objects +const SKIP_CONTAINER: &str = "skip_container"; + +#[derive(FromDeriveInput, Debug)] +#[darling(supports(enum_any))] +pub struct FromVariantInput { + ident: syn::Ident, + generics: syn::Generics, + data: darling::ast::Data, darling::util::Ignored>, +} + +// FromVariant manually implemented for additional validation +#[derive(Debug)] +struct FromVariantVariant { + ident: syn::Ident, + fields: darling::ast::Fields>, +} + +impl FromVariantVariant { + fn can_from_be_implemented( + fields: &darling::ast::Fields>, + ) -> bool { + fields.style == darling::ast::Style::Tuple && fields.fields.len() == 1 + } +} + +impl darling::FromVariant for FromVariantVariant { + fn from_variant(variant: &syn::Variant) -> darling::Result { + let ident = variant.ident.clone(); + let fields = darling::ast::Fields::try_from(&variant.fields)?; + let mut accumulator = darling::error::Accumulator::default(); + + let can_from_be_implemented = Self::can_from_be_implemented(&fields); + + for field in &fields.fields { + if (field.skip_from || field.skip_container) && !can_from_be_implemented { + accumulator.push(darling::Error::custom("#[skip_from], #[skip_try_from] and #[skip_container] attributes are only allowed for new-type enum variants (single unnamed field). The `From` traits will not be implemented for other kinds of variants").with_span(&field.span())); + } + } + + for attr in &variant.attrs { + let span = attr.span(); + let attr = attr.path().to_token_stream().to_string(); + match attr.as_str() { + SKIP_FROM_ATTR | SKIP_TRY_FROM_ATTR | SKIP_CONTAINER => { + accumulator.push( + darling::Error::custom(format!( + "#[{}] attribute should be applied to the field, not variant", + &attr + )) + .with_span(&span), + ); + } + _ => {} + } + } + + accumulator.finish()?; + + Ok(Self { ident, fields }) + } +} + +// FromField manually implemented for non-standard attributes +#[derive(Debug)] +struct FromVariantField { + ty: syn::Type, + skip_from: bool, + skip_try_from: bool, + skip_container: bool, +} + +// implementing manually, because darling can't parse attributes that are not under some unified attr +// It expects us to have a common attribute that will contain all the fields, like: +// #[hello(skip_from, skip_container)] +// The already defined macro API uses `skip_from` and `skip_container` attributes without any qualification +// Arguably, this is also more convenient for the user (?) +// Hence, we fall back to manual parsing +impl darling::FromField for FromVariantField { + fn from_field(field: &syn::Field) -> darling::Result { + let mut skip_from = false; + let mut skip_try_from = false; + let mut skip_container = false; + for attr in &field.attrs { + match attr.path().clone().to_token_stream().to_string().as_str() { + SKIP_FROM_ATTR => skip_from = true, + SKIP_TRY_FROM_ATTR => skip_try_from = true, + SKIP_CONTAINER => skip_container = true, + // ignore unknown attributes, rustc handles them + _ => continue, + } + } + Ok(Self { + ty: field.ty.clone(), + skip_from, + skip_try_from, + skip_container, + }) + } +} + +const CONTAINERS: &[&str] = &["Box", "RefCell", "Cell", "Rc", "Arc", "Mutex", "RwLock"]; + +fn get_type_argument<'b>(s: &str, ty: &'b syn::TypePath) -> Option<&'b syn::GenericArgument> { + // NOTE: this is NOT syn::Path::is_ident because it allows for generic parameters + let segments = &ty.path.segments; + if segments.len() != 1 || segments[0].ident != s { + return None; + } + + if let syn::PathArguments::AngleBracketed(ref bracketed_arguments) = segments[0].arguments { + assert_eq!(bracketed_arguments.args.len(), 1); + Some(&bracketed_arguments.args[0]) + } else { + unreachable!("No other arguments for types in enum variants possible") + } +} + +fn from_container_variant_internal( + into_ty: &syn::Ident, + into_variant: &syn::Ident, + from_ty: &syn::GenericArgument, + container_ty: &syn::TypePath, + generics: &syn::Generics, +) -> TokenStream { + let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); + + quote! { + impl #impl_generics core::convert::From<#from_ty> for #into_ty #ty_generics #where_clause { + fn from(origin: #from_ty) -> Self { + #into_ty :: #into_variant (#container_ty :: new(origin)) + } + } + } +} + +fn from_variant_internal( + span: Span, + into_ty: &syn::Ident, + into_variant: &syn::Ident, + from_ty: &syn::Type, + generics: &syn::Generics, +) -> TokenStream { + let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); + + quote_spanned! { span => + impl #impl_generics core::convert::From<#from_ty> for #into_ty #ty_generics #where_clause { + fn from(origin: #from_ty) -> Self { + #into_ty :: #into_variant (origin) + } + } + } +} + +fn from_variant( + span: Span, + into_ty: &syn::Ident, + into_variant: &syn::Ident, + from_ty: &syn::Type, + generics: &syn::Generics, + skip_container: bool, +) -> TokenStream { + let from_orig = from_variant_internal(span, into_ty, into_variant, from_ty, generics); + + if let syn::Type::Path(path) = from_ty { + let mut code = from_orig; + + if skip_container { + return code; + } + + for container in CONTAINERS { + if let Some(inner) = get_type_argument(container, path) { + let segments = path + .path + .segments + .iter() + .map(|segment| { + let mut segment = segment.clone(); + segment.arguments = syn::PathArguments::default(); + segment + }) + .collect::>(); + let path = syn::Path { + segments, + leading_colon: None, + }; + let path = &syn::TypePath { path, qself: None }; + + let from_inner = + from_container_variant_internal(into_ty, into_variant, inner, path, generics); + code = quote_spanned! { span => + #code + #from_inner + }; + } + } + + return code; + } + + from_orig +} + +fn try_into_variant_single( + span: Span, + enum_ty: &syn::Ident, + variant: &syn::Ident, + variant_ty: &syn::Type, + generics: &syn::Generics, +) -> TokenStream { + let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); + + quote_spanned! { span => + impl #impl_generics core::convert::TryFrom<#enum_ty #ty_generics> for #variant_ty #where_clause { + type Error = ::iroha_macro::error::ErrorTryFromEnum<#enum_ty #ty_generics, Self>; + + fn try_from(origin: #enum_ty #ty_generics) -> core::result::Result> { + let #enum_ty :: #variant(variant) = origin; + Ok(variant) + } + } + } +} + +fn try_into_variant( + span: Span, + enum_ty: &syn::Ident, + variant: &syn::Ident, + variant_ty: &syn::Type, + generics: &syn::Generics, +) -> TokenStream { + let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); + + quote_spanned! { span => + impl #impl_generics core::convert::TryFrom<#enum_ty #ty_generics> for #variant_ty #where_clause { + type Error = ::iroha_macro::error::ErrorTryFromEnum<#enum_ty #ty_generics, Self>; + + fn try_from(origin: #enum_ty #ty_generics) -> core::result::Result> { + if let #enum_ty :: #variant(variant) = origin { + Ok(variant) + } else { + Err(iroha_macro::error::ErrorTryFromEnum::default()) + } + } + } + } +} + +pub fn impl_from_variant(ast: &FromVariantInput) -> TokenStream { + let name = &ast.ident; + + let generics = &ast.generics; + + let enum_data = ast + .data + .as_ref() + .take_enum() + .expect("BUG: FromVariantInput is allowed to contain enum data only"); + let variant_count = enum_data.len(); + let froms = enum_data.into_iter().filter_map(|variant| { + if !variant.fields.is_newtype() { + return None; + } + let span = variant.span(); + let field = + variant.fields.iter().next().expect( + "BUG: FromVariantVariant should be newtype and thus contain exactly one field", + ); + let variant_type = &field.ty; + + let try_into = if field.skip_try_from { + quote!() + } else if variant_count == 1 { + try_into_variant_single(span, name, &variant.ident, variant_type, generics) + } else { + try_into_variant(span, name, &variant.ident, variant_type, generics) + }; + let from = if field.skip_from { + quote!() + } else if field.skip_container { + from_variant(span, name, &variant.ident, variant_type, generics, true) + } else { + from_variant(span, name, &variant.ident, variant_type, generics, false) + }; + + Some(quote!( + #try_into + #from + )) + }); + + quote! { #(#froms)* } +} diff --git a/crates/iroha_derive/src/lib.rs b/crates/iroha_derive/src/lib.rs index 1024a99f251..ea5c79c1ab2 100644 --- a/crates/iroha_derive/src/lib.rs +++ b/crates/iroha_derive/src/lib.rs @@ -1,16 +1,14 @@ //! Crate with various derive macros -use darling::{util::SpannedValue, FromDeriveInput}; -use manyhow::{manyhow, Result}; -use proc_macro2::{Span, TokenStream}; -use quote::{quote, quote_spanned, ToTokens}; -use syn::{spanned::Spanned, Token}; +use darling::FromDeriveInput as _; + +mod from_variant; +mod serde_where; -/// Attribute for skipping from attribute -const SKIP_FROM_ATTR: &str = "skip_from"; -const SKIP_TRY_FROM_ATTR: &str = "skip_try_from"; -/// Attribute to skip inner container optimization. Useful for trait objects -const SKIP_CONTAINER: &str = "skip_container"; +use iroha_macro_utils::Emitter; +use manyhow::{manyhow, Result}; +use proc_macro2::TokenStream; +use quote::{quote, ToTokens as _}; /// Helper macro to expand FFI functions #[manyhow] @@ -28,104 +26,6 @@ pub fn ffi_impl_opaque(_: TokenStream, item: TokenStream) -> Result }) } -#[derive(darling::FromDeriveInput, Debug)] -#[darling(supports(enum_any))] -struct FromVariantInput { - ident: syn::Ident, - generics: syn::Generics, - data: darling::ast::Data, darling::util::Ignored>, -} - -// FromVariant manually implemented for additional validation -#[derive(Debug)] -struct FromVariantVariant { - ident: syn::Ident, - fields: darling::ast::Fields>, -} - -impl FromVariantVariant { - fn can_from_be_implemented( - fields: &darling::ast::Fields>, - ) -> bool { - fields.style == darling::ast::Style::Tuple && fields.fields.len() == 1 - } -} - -impl darling::FromVariant for FromVariantVariant { - fn from_variant(variant: &syn::Variant) -> darling::Result { - let ident = variant.ident.clone(); - let fields = darling::ast::Fields::try_from(&variant.fields)?; - let mut accumulator = darling::error::Accumulator::default(); - - let can_from_be_implemented = Self::can_from_be_implemented(&fields); - - for field in &fields.fields { - if (field.skip_from || field.skip_container) && !can_from_be_implemented { - accumulator.push(darling::Error::custom("#[skip_from], #[skip_try_from] and #[skip_container] attributes are only allowed for new-type enum variants (single unnamed field). The `From` traits will not be implemented for other kinds of variants").with_span(&field.span())); - } - } - - for attr in &variant.attrs { - let span = attr.span(); - let attr = attr.path().to_token_stream().to_string(); - match attr.as_str() { - SKIP_FROM_ATTR | SKIP_TRY_FROM_ATTR | SKIP_CONTAINER => { - accumulator.push( - darling::Error::custom(format!( - "#[{}] attribute should be applied to the field, not variant", - &attr - )) - .with_span(&span), - ); - } - _ => {} - } - } - - accumulator.finish()?; - - Ok(Self { ident, fields }) - } -} - -// FromField manually implemented for non-standard attributes -#[derive(Debug)] -struct FromVariantField { - ty: syn::Type, - skip_from: bool, - skip_try_from: bool, - skip_container: bool, -} - -// implementing manually, because darling can't parse attributes that are not under some unified attr -// It expects us to have a common attribute that will contain all the fields, like: -// #[hello(skip_from, skip_container)] -// The already defined macro API uses `skip_from` and `skip_container` attributes without any qualification -// Arguably, this is also more convenient for the user (?) -// Hence, we fall back to manual parsing -impl darling::FromField for FromVariantField { - fn from_field(field: &syn::Field) -> darling::Result { - let mut skip_from = false; - let mut skip_try_from = false; - let mut skip_container = false; - for attr in &field.attrs { - match attr.path().clone().to_token_stream().to_string().as_str() { - SKIP_FROM_ATTR => skip_from = true, - SKIP_TRY_FROM_ATTR => skip_try_from = true, - SKIP_CONTAINER => skip_container = true, - // ignore unknown attributes, rustc handles them - _ => continue, - } - } - Ok(Self { - ty: field.ty.clone(), - skip_from, - skip_try_from, - skip_container, - }) - } -} - /// [`FromVariant`] is used for implementing `From for Enum` /// and `TryFrom for Variant`. /// @@ -159,200 +59,44 @@ impl darling::FromField for FromVariantField { #[proc_macro_derive(FromVariant, attributes(skip_from, skip_try_from, skip_container))] pub fn from_variant_derive(input: TokenStream) -> Result { let ast = syn::parse2(input)?; - let ast = FromVariantInput::from_derive_input(&ast)?; - Ok(impl_from_variant(&ast)) -} - -const CONTAINERS: &[&str] = &["Box", "RefCell", "Cell", "Rc", "Arc", "Mutex", "RwLock"]; - -fn get_type_argument<'b>(s: &str, ty: &'b syn::TypePath) -> Option<&'b syn::GenericArgument> { - // NOTE: this is NOT syn::Path::is_ident because it allows for generic parameters - let segments = &ty.path.segments; - if segments.len() != 1 || segments[0].ident != s { - return None; - } - - if let syn::PathArguments::AngleBracketed(ref bracketed_arguments) = segments[0].arguments { - assert_eq!(bracketed_arguments.args.len(), 1); - Some(&bracketed_arguments.args[0]) - } else { - unreachable!("No other arguments for types in enum variants possible") - } + let ast = from_variant::FromVariantInput::from_derive_input(&ast)?; + Ok(from_variant::impl_from_variant(&ast)) } -fn from_container_variant_internal( - into_ty: &syn::Ident, - into_variant: &syn::Ident, - from_ty: &syn::GenericArgument, - container_ty: &syn::TypePath, - generics: &syn::Generics, -) -> TokenStream { - let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); - - quote! { - impl #impl_generics core::convert::From<#from_ty> for #into_ty #ty_generics #where_clause { - fn from(origin: #from_ty) -> Self { - #into_ty :: #into_variant (#container_ty :: new(origin)) - } - } - } -} - -fn from_variant_internal( - span: Span, - into_ty: &syn::Ident, - into_variant: &syn::Ident, - from_ty: &syn::Type, - generics: &syn::Generics, -) -> TokenStream { - let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); - - quote_spanned! { span => - impl #impl_generics core::convert::From<#from_ty> for #into_ty #ty_generics #where_clause { - fn from(origin: #from_ty) -> Self { - #into_ty :: #into_variant (origin) - } - } - } -} - -fn from_variant( - span: Span, - into_ty: &syn::Ident, - into_variant: &syn::Ident, - from_ty: &syn::Type, - generics: &syn::Generics, - skip_container: bool, -) -> TokenStream { - let from_orig = from_variant_internal(span, into_ty, into_variant, from_ty, generics); - - if let syn::Type::Path(path) = from_ty { - let mut code = from_orig; - - if skip_container { - return code; - } - - for container in CONTAINERS { - if let Some(inner) = get_type_argument(container, path) { - let segments = path - .path - .segments - .iter() - .map(|segment| { - let mut segment = segment.clone(); - segment.arguments = syn::PathArguments::default(); - segment - }) - .collect::>(); - let path = syn::Path { - segments, - leading_colon: None, - }; - let path = &syn::TypePath { path, qself: None }; - - let from_inner = - from_container_variant_internal(into_ty, into_variant, inner, path, generics); - code = quote_spanned! { span => - #code - #from_inner - }; - } - } - - return code; - } - - from_orig -} - -fn try_into_variant_single( - span: Span, - enum_ty: &syn::Ident, - variant: &syn::Ident, - variant_ty: &syn::Type, - generics: &syn::Generics, -) -> TokenStream { - let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); - - quote_spanned! { span => - impl #impl_generics core::convert::TryFrom<#enum_ty #ty_generics> for #variant_ty #where_clause { - type Error = ::iroha_macro::error::ErrorTryFromEnum<#enum_ty #ty_generics, Self>; - - fn try_from(origin: #enum_ty #ty_generics) -> core::result::Result> { - let #enum_ty :: #variant(variant) = origin; - Ok(variant) - } - } - } -} - -fn try_into_variant( - span: Span, - enum_ty: &syn::Ident, - variant: &syn::Ident, - variant_ty: &syn::Type, - generics: &syn::Generics, -) -> TokenStream { - let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); - - quote_spanned! { span => - impl #impl_generics core::convert::TryFrom<#enum_ty #ty_generics> for #variant_ty #where_clause { - type Error = ::iroha_macro::error::ErrorTryFromEnum<#enum_ty #ty_generics, Self>; - - fn try_from(origin: #enum_ty #ty_generics) -> core::result::Result> { - if let #enum_ty :: #variant(variant) = origin { - Ok(variant) - } else { - Err(iroha_macro::error::ErrorTryFromEnum::default()) - } - } - } - } -} - -fn impl_from_variant(ast: &FromVariantInput) -> TokenStream { - let name = &ast.ident; - - let generics = &ast.generics; - - let enum_data = ast - .data - .as_ref() - .take_enum() - .expect("BUG: FromVariantInput is allowed to contain enum data only"); - let variant_count = enum_data.len(); - let froms = enum_data.into_iter().filter_map(|variant| { - if !variant.fields.is_newtype() { - return None; - } - let span = variant.span(); - let field = - variant.fields.iter().next().expect( - "BUG: FromVariantVariant should be newtype and thus contain exactly one field", - ); - let variant_type = &field.ty; - - let try_into = if field.skip_try_from { - quote!() - } else if variant_count == 1 { - try_into_variant_single(span, name, &variant.ident, variant_type, generics) - } else { - try_into_variant(span, name, &variant.ident, variant_type, generics) - }; - let from = if field.skip_from { - quote!() - } else if field.skip_container { - from_variant(span, name, &variant.ident, variant_type, generics, true) - } else { - from_variant(span, name, &variant.ident, variant_type, generics, false) - }; - - Some(quote!( - #try_into - #from - )) - }); - - quote! { #(#froms)* } +/// `#[serde_where]` attribute is a `derive-where`-like macro for serde, useful when associated types are used. +/// +/// It allows you to specify where bounds for `Serialize` and `Deserialize` traits with a more concise syntax. +/// +/// ```rust +/// use serde::{Deserialize, Serialize}; +/// +/// trait Trait { +/// type Assoc; +/// } +/// +/// #[serde_where(T::Assoc)] +/// #[derive(Serialize, Deserialize)] +/// struct Type { +/// field: T::Assoc, +/// } +/// ``` +#[manyhow] +#[proc_macro_attribute] +pub fn serde_where(arguments: TokenStream, item: TokenStream) -> TokenStream { + let mut emitter = Emitter::new(); + + let Some(derive_input) = emitter.handle(syn::parse2::(item.clone())) else { + // pass the input as-is, even if it's not a valid derive input + return emitter.finish_token_stream_with(item); + }; + let Some(arguments) = + emitter.handle(syn::parse2::(arguments)) + else { + // if we can't parse the arguments - pass the input as is + return emitter.finish_token_stream_with(derive_input.into_token_stream()); + }; + + let result = serde_where::impl_serde_where(&mut emitter, arguments, derive_input); + + emitter.finish_token_stream_with(result) } diff --git a/crates/iroha_derive/src/serde_where.rs b/crates/iroha_derive/src/serde_where.rs new file mode 100644 index 00000000000..f121564ab4f --- /dev/null +++ b/crates/iroha_derive/src/serde_where.rs @@ -0,0 +1,59 @@ +use iroha_macro_utils::Emitter; +use proc_macro2::TokenStream; +use quote::{ToTokens as _, TokenStreamExt as _}; +use syn::{parse_quote, Token}; + +#[derive(Debug)] +pub struct SerdeWhereArguments { + generics: Vec, +} + +impl syn::parse::Parse for SerdeWhereArguments { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let generics = syn::punctuated::Punctuated::<_, Token![,]>::parse_terminated(input)?; + + Ok(SerdeWhereArguments { + generics: generics.into_iter().collect(), + }) + } +} + +pub fn impl_serde_where( + _emitter: &mut Emitter, + arguments: SerdeWhereArguments, + mut input: syn::DeriveInput, +) -> TokenStream { + fn make_bound(arguments: &SerdeWhereArguments, f: F) -> String + where + F: Fn(&syn::Type) -> syn::WherePredicate, + { + let mut bound = TokenStream::new(); + + bound.append_separated( + arguments.generics.iter().map(f), + syn::token::Comma::default(), + ); + + bound.to_string() + } + + let serialize_bound = make_bound(&arguments, |ty| { + parse_quote! { + #ty: serde::Serialize + } + }); + let deserialize_bound = make_bound(&arguments, |ty| { + parse_quote! { + #ty: serde::Deserialize<'de> + } + }); + + input.attrs.push(syn::parse_quote! { + #[serde(bound( + serialize = #serialize_bound, + deserialize = #deserialize_bound, + ))] + }); + + input.to_token_stream() +} diff --git a/crates/iroha_derive/tests/serde_where.rs b/crates/iroha_derive/tests/serde_where.rs new file mode 100644 index 00000000000..c3b84c75f3e --- /dev/null +++ b/crates/iroha_derive/tests/serde_where.rs @@ -0,0 +1,12 @@ +use iroha_derive::serde_where; +use serde::{Deserialize, Serialize}; + +trait Trait { + type Assoc; +} + +#[serde_where(T::Assoc)] +#[derive(Serialize, Deserialize)] +struct Type { + field: T::Assoc, +} diff --git a/crates/iroha_primitives/src/small.rs b/crates/iroha_primitives/src/small.rs index a21a69e75ea..c6b5a4948cd 100644 --- a/crates/iroha_primitives/src/small.rs +++ b/crates/iroha_primitives/src/small.rs @@ -64,6 +64,8 @@ mod small_string { } mod small_vector { + use iroha_macro::serde_where; + use super::*; /// Wrapper struct around [`smallvec::SmallVec`] type. Keeps `N` @@ -76,14 +78,9 @@ mod small_vector { /// /// let a: SmallVec<[u8; 24]> = SmallVec(smallvec::smallvec![32]); /// ``` + #[serde_where(A::Item)] #[derive(Deserialize, Serialize)] - #[serde( - bound( - serialize = "A::Item: Serialize", - deserialize = "A::Item: Deserialize<'de>" - ), - transparent - )] + #[serde(transparent)] #[repr(transparent)] pub struct SmallVec(pub smallvec::SmallVec);