Macro extension_struct

Source
macro_rules! extension_struct {
    (
        $(#[doc = $comment:literal])*
        $struct_vis:vis struct $struct_name:ident$(<$struct_lt:lifetime>)*
        {
          $(
            $(#[$item_attr:meta])*
            $item_id:path => $item_vis:vis $item_slot:ident : Option<$item_ty:ty>,
          )+
        } $( + {
          $(
            $(#[$meta_attr:meta])*
            $meta_vis:vis $meta_slot:ident : $meta_ty:ty,
          )+
        })*
    ) => { ... };
}
Expand description

A macro which defines a structure containing TLS extensions

The contents are defined by two blocks, which are merged to give the struct’s items. The second block is optional.

The first block defines the items read-into by decoding, and used for encoding.

The type of each item in the first block must be an Option. This records the presence of that extension.

Each item in the first block is prefixed with a match arm, which must match an ExtensionType variant. This maps the item to its extension type.

Items in the second block are not encoded or decoded-to. They therefore must have a reasonable Default value.

All items must have a Default, Debug and Clone.