Macro der_parser::parse_der_set_defined_m
source · macro_rules! parse_der_set_defined_m {
($i:expr, $($args:tt)*) => { ... };
}
Expand description
Parse a set of DER elements (macro version)
Unlike parse_der_set
, this function allows to specify the
list of expected types in the DER set.
Similar to parse_der_set_defined
, but not using fold
.
This allow using macros.
use der_parser::*;
use nom::{IResult,Err,ErrorKind};
fn localparse_set(i:&[u8]) -> IResult<&[u8],DerObject> {
parse_der_set_defined_m!(i,
parse_der_integer >>
call!(parse_der_integer)
)
}
let empty = &b""[..];
let bytes = [ 0x31, 0x0a,
0x02, 0x03, 0x01, 0x00, 0x01,
0x02, 0x03, 0x01, 0x00, 0x00,
];
let expected = DerObject::from_obj(DerObjectContent::Set(vec![
DerObject::from_int_slice(b"\x01\x00\x01"),
DerObject::from_int_slice(b"\x01\x00\x00"),
]));
assert_eq!(localparse_set(&bytes), Ok((empty, expected)));