Crate notatin

source ·

Modules

Macros

  • Via https://github.com/omerbenamram/mft
  • This macro creates $enum_var of type {$class_name_prefix}Enum and initializes the appropriate variant depending on the value of $get_full_field_info
  • This macro generates three objects: {class_name_prefix}Light: A struct which contains FieldLight objects for each field (value only) {class_name_prefix}Full: A struct which contains FieldFull objects for each field (value, offset, and length) {class_name_prefix}Enum: An enum with variants for the above two structs Accessor and setter functions are created on {class_name_prefix}Enum for each field. A default() function is created for {class_name_prefix}Enum which creates a default {class_name_prefix}Light variant
  • This macro generates code which uses nom to read the specified data at the current $input. If $get_full_field_info is true, it will also determine the offset into the current buffer and the length of the data and generate the appropriate FieldTrait (FieldFull or FieldLight) object. Finally it will set the field in $struct_enum. Note that the value is made available outside of the macro in $var to ensure that the calling code has access to it for additional processing. Ex: read_value_offset_length! { input, start_pos_ptr, get_full_field_info, detail_enum, key_node_flag_bits, u16, le_u16 }