pub fn parse_ber_tagged_implicit<'a, T, F>(tag: T, f: F) -> impl FnMut(&'a [u8])
where F: Fn(&'a [u8], &Header<'_>, usize) -> Result<(&'a [u8], BerObjectContent<'a>), Err<Error>>, T: Into<Tag>,
Available on crate feature mtls only.
Expand description

Read a TAGGED IMPLICIT value (combinator)

Parse a TAGGED IMPLICIT value, given the expected tag, and the content parsing function.

The built object will use the original header (and tag), so the content may not match the tag value.

For a generic version (different output and error types), see parse_ber_tagged_implicit_g.

§Examples

The following parses [2] IMPLICIT INTEGER into a BerObject:

fn parse_int_implicit(i:&[u8]) -> BerResult<BerObject> {
    parse_ber_tagged_implicit(
        2,
        parse_ber_content(Tag::Integer),
    )(i)
}

let res = parse_int_implicit(bytes);

The following parses [2] IMPLICIT INTEGER into an u32, raising an error if the integer is too large:

use nom::combinator::map_res;
fn parse_int_implicit(i:&[u8]) -> BerResult<u32> {
    map_res(
        parse_ber_tagged_implicit(
            2,
            parse_ber_content(Tag::Integer),
        ),
        |x: BerObject| x.as_u32()
    )(i)
}

let res = parse_int_implicit(bytes);