README.md
1# rusticata-macros
2
3[](./LICENSE-MIT)
4[](./LICENSE-APACHE)
5[](https://travis-ci.org/rusticata/rusticata-macros)
6[](https://github.com/rusticata/rusticata-macros/actions)
7[](https://crates.io/crates/rusticata-macros)
8
9<!-- cargo-sync-readme start -->
10
11# Rusticata-macros
12
13Helper macros for the [rusticata](https://github.com/rusticata) project.
14
15This crate contains some additions to [nom](https://github.com/Geal/nom).
16
17For example, the [`combinator::cond_else`] function allows to apply the first parser if the
18condition is true, and the second if the condition is false:
19
20```rust
21use rusticata_macros::combinator::cond_else;
22let r: IResult<_, _, ()> = cond_else(
23 || s.len() > 1,
24 be_u16,
25 map(be_u8, u16::from)
26 )(s);
27```
28
29See the documentation for more details and examples.
30
31<!-- cargo-sync-readme end -->
32
33## Nom versions
34
35Different versions of this crate are available, depending on nom version.
36
37- `rusticata-macros` 4.x depends on nom 7
38- `rusticata-macros` 3.x depends on nom 6
39- `rusticata-macros` 2.x depends on nom 5
40
41## Documentation
42
43Crate is documented, do running `cargo doc` will crate the offline documentation.
44
45Reference documentation can be found [here](https://docs.rs/rusticata-macros/)
46
47## Changes
48
49### 4.1.0
50
51- Remove macro `slice_fixed`
52
53### 4.0.0
54
55- Upgrade to nom 7
56 - Remove macros
57
58### 3.0.1
59
60- Add `be_var_u64` and `le_var_u64`
61
62### 3.0.0
63
64- Upgrade to nom 6
65
66### 2.1.0
67
68- Add common trait `Serialize` for structures serialization
69
70### 2.0.4
71
72- Add function version of most combinators
73
74### 2.0.3
75
76- Add macros `q` (quote) and `align32`
77
78### 2.0.2
79
80- Add `upgrade_error` and `upgrade_error_to`
81
82### 2.0.1
83
84- Add macro `custom_check`
85- Add macro `flat_take`
86
87### 2.0.0
88
89- Upgrade to nom 5
90- Debug types: use newtypes
91
92### 1.1.0
93
94- Add macro `newtype_enum`
95
96### 1.0.0
97
98- Upgrade to nom 4.0
99 - Warning: this is a breaking change!
100- Mark `parse_uint24` as deprecated
101
102## License
103
104Licensed under either of
105
106 * Apache License, Version 2.0
107 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
108 * MIT license
109 ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
110
111at your option.
112
113## Contribution
114
115Unless you explicitly state otherwise, any contribution intentionally submitted
116for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
117dual licensed as above, without any additional terms or conditions.
118
119