Macro for composing custom message handlers
authorJeffrey Czyz <jkczyz@gmail.com>
Tue, 3 Jan 2023 17:24:30 +0000 (11:24 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 15 Feb 2023 00:20:40 +0000 (18:20 -0600)
commit6e0384e39cca9016015e5b8d9ce98c1e86c750c8
tree095604fbb4e777db19ae57787a3c22f4dac466c5
parentbe4bb58573ab6f56f363496574d64fa83074364b
Macro for composing custom message handlers

BOLT 1 specifies a custom message type range for use with experimental
or application-specific messages. While a `CustomMessageHandler` can be
defined to support more than one message type, defining such a handler
requires a significant amount of boilerplate and can be error prone.

Add a crate exporting a `composite_custom_message_handler` macro for
easily composing pre-defined custom message handlers. The resulting
handler can be further composed with other custom message handlers using
the same macro.

This requires a separate crate since the macro needs to support "or"
patterns in macro_rules, which is only available in edition 2021.

https://doc.rust-lang.org/edition-guide/rust-2021/or-patterns-macro-rules.html

Otherwise, a crate defining a handler for a set of custom messages could
not easily be reused with another custom message handler. Doing so would
require explicitly duplicating the reused handlers type ids, but those
may change when the crate is updated.
.gitignore
Cargo.toml
lightning-custom-message/Cargo.toml [new file with mode: 0644]
lightning-custom-message/src/lib.rs [new file with mode: 0644]