blob: c6f4344df8131315b917a0ee3da7b29fc4862614 [file] [log] [blame]
Yiming Jingebb18722021-07-16 13:15:12 -07001//! # Rusticata-macros
2//!
3//! Helper macros for the [rusticata](https://github.com/rusticata) project.
4//!
5//! This crate contains some additions to [nom](https://github.com/Geal/nom).
6//!
7//! For example, the `error_if!` macro allows to test a condition and return an error from the parser if the condition
8//! fails:
9//!
10//! ```rust
11//! # extern crate rusticata_macros;
12//! # extern crate nom;
13//! # use nom::{do_parse, take, IResult};
14//! # use nom::error::ErrorKind;
15//! # use nom::number::streaming::be_u8;
16//! use rusticata_macros::error_if;
17//! # fn parser(s:&[u8]) {
18//! let r : IResult<&[u8],()> = do_parse!(
19//! s,
20//! l: be_u8 >>
21//! error_if!(l < 4, ErrorKind::Verify) >>
22//! data: take!(l - 4) >>
23//! (())
24//! );
25//! # }
26//! ```
27//!
28//! See the documentation for more details and examples.
29
30#![deny(
31 missing_docs,
32 unsafe_code,
33 unstable_features,
34 unused_import_braces,
35 unused_qualifications
36)]
37
38#[macro_use]
39extern crate nom;
40
41extern crate core;
42
43pub mod combinator;
44
45pub use macros::*;
46#[macro_use]
47pub mod macros;
48
49pub mod debug;
50mod traits;
51pub use traits::*;