Function der_parser::der::parse_der_tagged_implicit
source · pub fn parse_der_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_der_tagged_implicit_g.
§Examples
The following parses [2] IMPLICIT INTEGER
into a DerObject
:
fn parse_int_implicit(i:&[u8]) -> BerResult<DerObject> {
parse_der_tagged_implicit(
2,
parse_der_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_der_tagged_implicit(
2,
parse_der_content(Tag::Integer),
),
|x: DerObject| x.as_u32()
)(i)
}
let res = parse_int_implicit(bytes);