[][src]Macro der_parser::parse_der_sequence_defined_m

macro_rules! parse_der_sequence_defined_m {
    ($i:expr, $($args:tt)*) => { ... };
}

Parse a sequence of DER elements (macro version)

Unlike parse_der_sequence, this function allows to specify the list of expected types in the DER sequence.

Similar to parse_der_sequence_defined, but not using fold. This allow using macros.

use der_parser::ber::*;
use nom::{IResult,Err,ErrorKind};

fn localparse_seq(i:&[u8]) -> IResult<&[u8],BerObject> {
    parse_der_sequence_defined_m!(i,
        parse_ber_integer >>
        call!(parse_ber_integer)
    )
}
let empty = &b""[..];
let bytes = [ 0x30, 0x0a,
              0x02, 0x03, 0x01, 0x00, 0x01,
              0x02, 0x03, 0x01, 0x00, 0x00,
];
let expected  = BerObject::from_seq(vec![
    BerObject::from_int_slice(b"\x01\x00\x01"),
    BerObject::from_int_slice(b"\x01\x00\x00"),
]);
assert_eq!(localparse_seq(&bytes), Ok((empty, expected)));