blob: 42cd1fdf37d7caa992c7c22ee3b456fac49d60d1 [file] [log] [blame] [view]
Yiming Jingebb18722021-07-16 13:15:12 -07001# rusticata-macros
2
3[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE-MIT)
4[![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE-APACHE)
5[![Build Status](https://travis-ci.org/rusticata/rusticata-macros.svg?branch=master)](https://travis-ci.org/rusticata/rusticata-macros)
6[![Github CI](https://github.com/rusticata/rusticata-macros/workflows/Continuous%20integration/badge.svg)](https://github.com/rusticata/rusticata-macros/actions)
7[![Crates.io Version](https://img.shields.io/crates/v/rusticata-macros.svg)](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 `error_if!` macro allows to test a condition and return an error from the parser if the condition
18fails:
19
20```rust
21use rusticata_macros::error_if;
22let r : IResult<&[u8],()> = do_parse!(
23 s,
24 l: be_u8 >>
25 error_if!(l < 4, ErrorKind::Verify) >>
26 data: take!(l - 4) >>
27 (())
28 );
29```
30
31See the documentation for more details and examples.
32
33<!-- cargo-sync-readme end -->
34
35## Nom versions
36
37Different versions of this crate are available, depending on nom version.
38
Joel Galensondcd5c522021-09-22 11:16:43 -070039- `rusticata-macros` 4.x depends on nom 7
40- `rusticata-macros` 3.x depends on nom 6
41- `rusticata-macros` 2.x depends on nom 5
Yiming Jingebb18722021-07-16 13:15:12 -070042
43## Documentation
44
45Crate is documented, do running `cargo doc` will crate the offline documentation.
46
47Reference documentation can be found [here](https://docs.rs/rusticata-macros/)
48
49## Changes
50
Joel Galensondcd5c522021-09-22 11:16:43 -070051### 4.0.0
52
53- Upgrade to nom 7
54 - Remove macros
55
Yiming Jingebb18722021-07-16 13:15:12 -070056### 3.0.1
57
58- Add `be_var_u64` and `le_var_u64`
59
60### 3.0.0
61
62- Upgrade to nom 6
63
64### 2.1.0
65
66- Add common trait `Serialize` for structures serialization
67
68### 2.0.4
69
70- Add function version of most combinators
71
72### 2.0.3
73
74- Add macros `q` (quote) and `align32`
75
76### 2.0.2
77
78- Add `upgrade_error` and `upgrade_error_to`
79
80### 2.0.1
81
82- Add macro `custom_check`
83- Add macro `flat_take`
84
85### 2.0.0
86
87- Upgrade to nom 5
88- Debug types: use newtypes
89
90### 1.1.0
91
92- Add macro `newtype_enum`
93
94### 1.0.0
95
96- Upgrade to nom 4.0
97 - Warning: this is a breaking change!
98- Mark `parse_uint24` as deprecated
99
100## License
101
102Licensed under either of
103
104 * Apache License, Version 2.0
105 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
106 * MIT license
107 ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
108
109at your option.
110
111## Contribution
112
113Unless you explicitly state otherwise, any contribution intentionally submitted
114for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
115dual licensed as above, without any additional terms or conditions.
116