Yiming Jing | ebb1872 | 2021-07-16 13:15:12 -0700 | [diff] [blame] | 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 | |
| 13 | Helper macros for the [rusticata](https://github.com/rusticata) project. |
| 14 | |
| 15 | This crate contains some additions to [nom](https://github.com/Geal/nom). |
| 16 | |
| 17 | For example, the `error_if!` macro allows to test a condition and return an error from the parser if the condition |
| 18 | fails: |
| 19 | |
| 20 | ```rust |
| 21 | use rusticata_macros::error_if; |
| 22 | let 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 | |
| 31 | See the documentation for more details and examples. |
| 32 | |
| 33 | <!-- cargo-sync-readme end --> |
| 34 | |
| 35 | ## Nom versions |
| 36 | |
| 37 | Different versions of this crate are available, depending on nom version. |
| 38 | |
Joel Galenson | dcd5c52 | 2021-09-22 11:16:43 -0700 | [diff] [blame] | 39 | - `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 Jing | ebb1872 | 2021-07-16 13:15:12 -0700 | [diff] [blame] | 42 | |
| 43 | ## Documentation |
| 44 | |
| 45 | Crate is documented, do running `cargo doc` will crate the offline documentation. |
| 46 | |
| 47 | Reference documentation can be found [here](https://docs.rs/rusticata-macros/) |
| 48 | |
| 49 | ## Changes |
| 50 | |
Joel Galenson | dcd5c52 | 2021-09-22 11:16:43 -0700 | [diff] [blame] | 51 | ### 4.0.0 |
| 52 | |
| 53 | - Upgrade to nom 7 |
| 54 | - Remove macros |
| 55 | |
Yiming Jing | ebb1872 | 2021-07-16 13:15:12 -0700 | [diff] [blame] | 56 | ### 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 | |
| 102 | Licensed 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 | |
| 109 | at your option. |
| 110 | |
| 111 | ## Contribution |
| 112 | |
| 113 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 114 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
| 115 | dual licensed as above, without any additional terms or conditions. |
| 116 | |