Macro impl_writeable_tlv_based_enum

Source
macro_rules! impl_writeable_tlv_based_enum {
    ($st: ident,
        $(($variant_id: expr, $variant_name: ident) =>
            {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}
        ),*
        $($(,)? {$tuple_variant_id: expr, $tuple_variant_name: ident} => ()),*
        $(,)?
    ) => { ... };
}
Expand description

Implement Readable and Writeable for an enum, with struct variants stored as TLVs and tuple variants stored directly.

The format is, for example,

enum EnumName {
  StructVariantA {
    required_variant_field: u64,
    optional_variant_field: Option<u8>,
  },
  StructVariantB {
    variant_field_a: bool,
    variant_field_b: u32,
    variant_vec_field: Vec<u32>,
  },
  TupleVariantA(),
  TupleVariantB(Vec<u8>),
}

The type is written as a single byte, followed by length-prefixed variant data.

Attempts to read an unknown type byte result in DecodeError::UnknownRequiredFeature.

Note that the serialization for tuple variants (as well as the call format) was changed in LDK 0.0.124.