From dbc84463daedf1563f7cc8f5ee995a919921973d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Klaehn?= Date: Thu, 4 Jul 2024 20:08:33 +0300 Subject: [PATCH] refactor(iroh): Modularize protocol (#2454) ## Description Use a newly created macro crate https://github.com/n0-computer/nested-enum-utils to allow for from/to conversions for deeply nested enums. This allows us to split the protocol enum into multiple parts without changing anything about the basic concept of how things are handled. ## Breaking Changes Weirdly, I think there should be none since the protocol is private. ## Notes & open questions Obvious next steps would be - [x] define the subsystem specific messages in submodules - [x] publish the macro crate - [x] (maybe) split up the handling of the different subsystems - [x] (maybe) remove the subsystem prefixes from the messages Not so obvious next steps (maybe next PR) - Allow moving the subsystem protocols to different crates. This is difficult because you can not set the target when generating the conversions. ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant. - [x] All breaking changes documented. --- Cargo.lock | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 731848f256..41c7268343 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2452,6 +2452,7 @@ dependencies = [ "iroh-net", "iroh-quinn", "iroh-test", + "nested_enum_utils", "num_cpus", "parking_lot", "portable-atomic", @@ -3175,6 +3176,18 @@ dependencies = [ "getrandom", ] +[[package]] +name = "nested_enum_utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f256ef99e7ac37428ef98c89bef9d84b590172de4bbfbe81b68a4cd3abadb32" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "netdev" version = "0.29.0"