Skip to main content

define_channels_insns_and_automatic_impls

Macro define_channels_insns_and_automatic_impls 

Source
macro_rules! define_channels_insns_and_automatic_impls {
    { $(
    $( #[doc $($doc_attr:tt)*] )*
    $( #[field $other_attr:meta] )*
    $field:ident : $ty:ty
),* $(,)? } => { ... };
}
Expand description

Generate most of the types and methods relating to ChannelPaddingInstructions: things which contain or process all instructions fields (or each one)

There is one call to this macro, which has as argument the body of struct ChannelPaddingInstructions, with the following differences:

  • field visibility specifiers are not specified; they are provided by the macro
  • non-doc attributes that ought to be applied to fields in ChannelPaddingInstructions are prefixed with field, e.g. #[field educe(Default ...)]; this allows applying doc attributes to other items too.

Generates, fairly straightforwardly:

pub struct ChannelPaddingInstructions { ... } // containing the fields as specified
pub struct ChannelPaddingInstructionsUpdates { ... } // containing `Option` of each field
pub fn ChannelPaddingInstructions::initial_update(&self) -> ChannelPaddingInstructionsUpdates;
pub fn ChannelPaddingInstructionsUpdatesBuilder::$field(self, new_value: _) -> Self;

Within the macro body, we indent the per-field $( )* with 2 spaces.