Expand description

Rusticata-macros

Helper macros for the rusticata project.

This crate contains some additions to nom.

For example, the combinator::cond_else function allows to apply the first parser if the condition is true, and the second if the condition is false:

use rusticata_macros::combinator::cond_else;
let r: IResult<_, _, ()> = cond_else(
        || s.len() > 1,
        be_u16,
        map(be_u8, u16::from)
    )(s);

See the documentation for more details and examples.

Re-exports

pub use macros::*;
pub use nom;

Modules

General purpose combinators

Helper functions and structures for debugging purpose

Helper macros

Macros

Align input value to the next multiple of 4 bytes

Align input value to the next multiple of n bytes Valid only if n is a power of 2

Helper macro for nom parsers: raise error if the condition is true

emptyDeprecated

Helper macro for nom parsers: raise error if input is not empty

Helper macro for nom parsers: raise error if the condition is true

Combination and flat_map! and take! as first combinator

Helper macro for newtypes: declare associated constants and implement Display trait

Read a slice as a big-endian value.

Nom combinator that returns the given expression unchanged

Apply combinator, trying to “upgrade” error to next error type (using the Into or From traits).

Apply combinator, trying to “upgrade” error to next error type (using the Into or From traits).

Traits

Common trait for structures serialization