[][src]Crate rusticata_macros

Rusticata-macros

Helper macros for the rusticata project.

This crate contains some additions to nom.

For example, the error_if! macro allows to test a condition and return an error from the parser if the condition fails:

use rusticata_macros::error_if;
let r : IResult<&[u8],()> = do_parse!(
    s,
    l: be_u8 >>
    error_if!(l < 4, ErrorKind::Verify) >>
    data: take!(l - 4) >>
    (())
    );

See the documentation for more details and examples.

Re-exports

pub use macros::*;

Modules

combinator

General purpose combinators

debug

Helper functions and structures for debugging purpose

macros

Helper macros

Macros

align32

Align input value to the next multiple of 4 bytes

align_n2

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

cond_else

Helper macro for nom parsers: run first parser if condition is true, else second parser

custom_check

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

emptyDeprecated

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

error_if

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

flat_take

Combination and flat_map! and take! as first combinator

newtype_enum

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

parse_hex_to_u64

Read a slice as a big-endian value.

q

Nom combinator that returns the given expression unchanged

slice_fixed

Parse a slice and return a fixed-sized array of bytes

upgrade_error

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

upgrade_error_to

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

Traits

Serialize

Common trait for structures serialization