generate_function_selector

Attribute Macro generate_function_selector 

Source
#[generate_function_selector]
Expand description

This macro allows to associate to each variant of an enumeration a discriminant (of type u32 whose value corresponds to the first 4 bytes of the Hash Keccak256 of the character string indicated by the user of this macro.

Usage:

#[evm_precompiles_derive::generate_function_selector]
enum Action {
    Toto = "toto()",
    Tata = "tata()",
}

Extanded to:

#[repr(u32)]
enum Action {
    Toto = 119097542u32,
    Tata = 1414311903u32,
}