Skip to content

Commit

Permalink
Merge pull request #7 from archaelus/nom_3_0_upgrade
Browse files Browse the repository at this point in the history
Nom 3.0 upgrade
  • Loading branch information
richo authored May 24, 2017
2 parents baf8c05 + 18cb419 commit 012771f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ license = "MIT"
documentation = "http://richo.psych0tik.net/pcapng-rs/pcapng/"

[dependencies]
nom = "^2.0"
nom = "^3.0"
15 changes: 8 additions & 7 deletions examples/producer_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ extern crate nom;
extern crate pcapng;

use std::env;
use nom::{FileProducer,Producer,ConsumerState};
use nom::{IResult,FileProducer,Producer,ConsumerState};
use pcapng::block::parse_block;

use std::fmt::Debug;
pub fn print_block<T: Debug>(input: T) -> IResult<T,()> {
println!("{:?}", input);
IResult::Done(input, ())
}

consumer_from_parser!(Printer<()>,
chain!(
block: parse_block ,
||{
println!("{:?}", block);
}
));
flat_map!(parse_block, print_block));

fn main() {
let args: Vec<_> = env::args().collect();
Expand Down
2 changes: 2 additions & 0 deletions src/blocks/constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(non_camel_case_types)]

#[repr(C)]
#[derive(Debug, Eq, PartialEq)]
pub enum BlockType {
Expand Down
14 changes: 7 additions & 7 deletions src/blocks/interface_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub const TY: u32 = BlockType::InterfaceStatistics as u32;
// +---------------------------------------------------------------+

named!(interface_stats_body<&[u8], InterfaceStatistics>,
chain!(
interface_id: le_u32 ~
timestamp_high: le_u32 ~
timestamp_low: le_u32 ~
options: opt!(complete!(parse_options)),
||{
do_parse!(
interface_id: le_u32 >>
timestamp_high: le_u32 >>
timestamp_low: le_u32 >>
options: opt!(complete!(parse_options)) >>
(
InterfaceStatistics {
ty: TY,
block_length: 0,
Expand All @@ -42,7 +42,7 @@ named!(interface_stats_body<&[u8], InterfaceStatistics>,
check_length: 0,
}

}
)
)
);

Expand Down

0 comments on commit 012771f

Please sign in to comment.