Skip to content

Commit 084e2dc

Browse files
committed
f - fixup docs
1 parent 6d60e7f commit 084e2dc

File tree

1 file changed

+17
-2
lines changed
  • lightning-custom-message/src

1 file changed

+17
-2
lines changed

lightning-custom-message/src/lib.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
//! defining such a handler requires a significant amount of boilerplate and can be error prone.
66
//!
77
//! This crate provides the [`composite_custom_message_handler`] macro for easily composing
8-
//! pre-defined custom message handlers. The resulting handler can be further composed with other
9-
//! custom message handlers using the same macro.
8+
//! pre-defined custom message handlers into one handler. The resulting handler can be further
9+
//! composed with other custom message handlers using the same macro.
1010
//!
1111
//! The following example demonstrates defining a `FooBarHandler` to compose separate handlers for
1212
//! `Foo` and `Bar` messages, and further composing it with a handler for `Baz` messages.
@@ -25,6 +25,9 @@
2525
//! use lightning::util::ser::Writeable;
2626
//! # use lightning::util::ser::Writer;
2727
//!
28+
//! // Assume that `FooHandler` and `BarHandler` are defined in one crate and `BazHandler` is
29+
//! // defined in another crate, handling messages `Foo`, `Bar`, and `Baz`, respectively.
30+
//!
2831
//! #[derive(Debug)]
2932
//! pub struct Foo;
3033
//!
@@ -146,6 +149,9 @@
146149
//! }
147150
//!
148151
//! # fn main() {
152+
//! // The first crate may define a handler composing `FooHandler` and `BarHandler` and export the
153+
//! // corresponding message type ids as a macro to use in further composition.
154+
//!
149155
//! composite_custom_message_handler!(
150156
//! pub struct FooBarHandler {
151157
//! foo: FooHandler,
@@ -158,10 +164,14 @@
158164
//! }
159165
//! );
160166
//!
167+
//! #[macro_export]
161168
//! macro_rules! foo_bar_type_ids {
162169
//! () => { foo_type_id!() | bar_type_id!() }
163170
//! }
164171
//!
172+
//! // Another crate can then define a handler further composing `FooBarHandler` with `BazHandler`
173+
//! // and similarly export the composition of message type ids as a macro.
174+
//!
165175
//! composite_custom_message_handler!(
166176
//! pub struct FooBarBazHandler {
167177
//! foo_bar: FooBarHandler,
@@ -173,6 +183,11 @@
173183
//! Baz(baz_type_id!()),
174184
//! }
175185
//! );
186+
//!
187+
//! #[macro_export]
188+
//! macro_rules! foo_bar_baz_type_ids {
189+
//! () => { foo_bar_type_ids!() | baz_type_id!() }
190+
//! }
176191
//! # }
177192
//!```
178193
//!

0 commit comments

Comments
 (0)