• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! # 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 [`combinator::cond_else`] function allows to apply the first parser if the
8 //! condition is true, and the second if the condition is false:
9 //!
10 //! ```rust
11 //! # use nom::IResult;
12 //! # use nom::combinator::map;
13 //! # use nom::number::streaming::*;
14 //! use rusticata_macros::combinator::cond_else;
15 //! # fn parser(s:&[u8]) {
16 //! let r: IResult<_, _, ()> = cond_else(
17 //!         || s.len() > 1,
18 //!         be_u16,
19 //!         map(be_u8, u16::from)
20 //!     )(s);
21 //! # }
22 //! ```
23 //!
24 //! See the documentation for more details and examples.
25 
26 #![deny(
27     missing_docs,
28     unsafe_code,
29     unstable_features,
30     unused_import_braces,
31     unused_qualifications
32 )]
33 
34 pub mod combinator;
35 pub mod debug;
36 pub use macros::*;
37 #[macro_use]
38 pub mod macros;
39 
40 mod traits;
41 pub use traits::*;
42 
43 // re-exports
44 pub use nom;
45