pub fn parse_der_tagged_implicit_g<'a, T, Output, F, E>(
tag: T,
f: F,
) -> impl FnMut(&'a [u8]) -> IResult<&[u8], Output, E>
Expand description
Read a TAGGED IMPLICIT value (generic version)
Parse a TAGGED IMPLICIT value, given the expected tag, and the content parsing function.
ยงExamples
The following parses [1] IMPLICIT OCTETSTRING
, returning a DerObject
:
fn parse_implicit_0_octetstring(i:&[u8]) -> BerResult<DerObjectContent> {
parse_der_tagged_implicit_g(
2,
parse_der_content2(Tag::OctetString)
)(i)
}
let res = parse_implicit_0_octetstring(bytes);
The following parses [2] IMPLICIT INTEGER
into an u32
, raising an error if the integer is
too large:
fn parse_int_implicit(i:&[u8]) -> BerResult<u32> {
parse_der_tagged_implicit_g(
2,
|content, hdr, depth| {
let (rem, obj_content) = parse_der_content(Tag::Integer)(content, &hdr, depth)?;
let value = obj_content.as_u32()?;
Ok((rem, value))
}
)(i)
}
let res = parse_int_implicit(bytes);