pub fn parse_ber_tagged_implicit<'a, T, F>(
tag: T,
f: F,
) -> impl FnMut(&'a [u8]) -> BerResult<'_>
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);