breez_sdk_liquid::lightning

Macro impl_writeable_msg

macro_rules! impl_writeable_msg {
    ($st:ident, {$($field:ident),* $(,)*}, {$(($type: expr, $tlvfield: ident, $fieldty: tt)),* $(,)*}) => { ... };
}
Expand description

Implements Readable/Writeable for a message struct that may include non-TLV and TLV-encoded parts.

This is useful to implement a CustomMessageReader.

Currently $fieldty may only be option, i.e., $tlvfield is optional field.

For example,

struct MyCustomMessage {
	pub field_1: u32,
	pub field_2: bool,
	pub field_3: String,
	pub tlv_optional_integer: Option<u32>,
}

impl_writeable_msg!(MyCustomMessage, {
	field_1,
	field_2,
	field_3
}, {
	(1, tlv_optional_integer, option),
});