macro_rules! generate_slot_range {
($( $x:ident ( $e:expr ) ),*) => { ... };
(@inner
{ $( $parsed:ident ( $t1:expr, $t2:expr ) )* }
$current:ident ( $ce:expr )
$( $remaining:ident ( $re:expr ) )*
) => { ... };
(@inner
{ $( $parsed:ident ( $t1:expr, $t2:expr ) )* }
) => { ... };
}Expand description
This macro generates a SlotRange enum of arbitrary length for use in the Slot Auction
mechanism on Polkadot.
Usage:
slot_range_helper::generate_slot_range!(Zero(0), One(1), Two(2), Three(3));To extend the usage, continue to add Identifier(value) items to the macro.
This will generate an enum SlotRange with the following properties:
- Enum variants will range from all consecutive combinations of inputs, i.e.
ZeroZero,ZeroOne,ZeroTwo,ZeroThree,OneOne,OneTwo,OneThree… - A constant
LEASE_PERIODS_PER_SLOTwill count the number of lease periods. - A constant
SLOT_RANGE_COUNTwill count the total number of enum variants. - A function
as_pairwill return a tuple representation of theSlotRange. - A function
intersectswill tell you if two slot ranges intersect with one another. - A function
lenwill tell you the length of occupying aSlotRange. - A function
new_boundedwill generate aSlotRangefrom an input of the current lease period, the starting lease period, and the final lease period.