pub fn parse_ber_tagged_explicit_g<'a, T, Output, F, E>(
    tag: T,
    f: F
) -> impl FnMut(&'a [u8])
where F: Fn(&'a [u8], Header<'a>) -> Result<(&'a [u8], Output), Err<E>>, E: ParseError<&'a [u8]> + From<Error>, T: Into<Tag>,
Available on crate feature mtls only.
Expand description

Read a TAGGED EXPLICIT value (generic version)

The following parses [2] EXPLICIT INTEGER:

fn parse_int_explicit(i:&[u8]) -> BerResult<u32> {
    parse_ber_tagged_explicit_g(2, move |content, hdr| {
        let (rem, obj) = parse_ber_integer(content)?;
        let value = obj.as_u32()?;
        Ok((rem, value))
   })(i)
}

let res = parse_int_explicit(bytes);