Skip to main content

Parse

Derive Macro Parse 

Source
#[derive(Parse)]
{
    // Attributes available to this derive:
    #[pad_to_alignment]
    #[parse_additional_args]
    #[validate]
    #[assert_offset]
}
Expand description

Auto-implements the Parse trait. Can be applied using #[derive(Parse)]. Attributes:

  • #[validate(callback)]: Extra validation logic. This should go at the beginning of the struct declaration.
  • #[assert_offset(n)]: Ensures a struct field has offset n from the beginning of the struct.
  • #[pad_to_alignment(n)]: Attaches to a struct field to add up to n bytes of padding.
  • #[parse_additional_args(arg1, arg2)]: Attaches to a struct field. Includes additional arguments to be provided to that field’s ::parse method.