Skip to main content

Crate onenote_parser_macros

Crate onenote_parser_macros 

Source
Expand description

Internal proc-macro support crate for onenote_parser.

This crate provides #[derive(Parse)], which is used by the parser’s low-level OneStore/OneNote decoding types to reduce handwritten binary parsing boilerplate.

It is intended for internal use inside this workspace. Most users should use the high-level onenote_parser crate API instead of depending on this crate directly.

The derive generates an implementation of crate::onestore::desktop::parse::Parse for a struct by parsing each field in declaration order from a shared reader.

§Supported attributes

  • #[validate(expr)] (struct-level): Runs after field parsing and returns ParseValidationFailed when expr evaluates to false.
  • #[assert_offset(n)] (field-level): Validates that a field starts at byte offset n from the start of the struct.
  • #[pad_to_alignment(n)] (field-level): Advances the reader by up to n - 1 bytes after parsing a field to align subsequent parsing.
  • #[parse_additional_args(args)] (field-level): Passes extra arguments to a field type’s ::parse(...) call.

§Scope and limitations

  • Only named-field structs are currently implemented.
  • Tuple structs, unit structs, enums, and unions are not yet supported.

Derive Macros§

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