Crate rusticata_macros

Source
Available on crate feature mtls only.
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.

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
custom_check
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
error_if
Helper macro for nom parsers: raise error if the condition is true
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
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

Functions§

bytes_to_u64Deprecated
Read an entire slice as a big-endian value.
parse_uint24Deprecated
Read 3 bytes as an unsigned integer