Macro der_parser::parse_der_sequence_of [] [src]

macro_rules! parse_der_sequence_of {
    ($i:expr, $f:ident) => { ... };
}

Parse a sequence of identical DER elements

Given a subparser for a DER type, parse a sequence of identical objects.

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

fn parser(i:&[u8]) -> IResult<&[u8],DerObject> {
    parse_der_sequence_of!(i, parse_der_integer)
};
let empty = &b""[..];
let bytes = [ 0x30, 0x0a,
              0x02, 0x03, 0x01, 0x00, 0x01,
              0x02, 0x03, 0x01, 0x00, 0x00,
];
let expected  = DerObject::from_obj(DerObjectContent::Sequence(vec![
    DerObject::from_int_slice(b"\x01\x00\x01"),
    DerObject::from_int_slice(b"\x01\x00\x00"),
]));
assert_eq!(parser(&bytes), IResult::Done(empty, expected));