Function rocket::mtls::x509::der_parser::ber::parse_ber_content2

source ·
pub fn parse_ber_content2<'a>(tag: Tag) -> impl Fn(&'a [u8], Header<'a>, usize)
Available on crate feature mtls only.
Expand description

Parse the next bytes as the content of a BER object (combinator, owned header)

Content type is not checked to match tag, caller is responsible of providing the correct tag

Caller is also responsible to check if parsing function consumed the expected number of bytes (header.len).

The arguments of the parse function are: (input, ber_object_header, max_recursion).

This function differs from parse_ber_content because it passes an owned BER object header (required for ex. by parse_ber_tagged_implicit_g).

Example: manually parsing header and content

let (i, header) = ber_read_element_header(bytes).expect("parsing failed");
let (rem, content) = parse_ber_content(header.tag())(i, &header, MAX_RECURSION)
    .expect("parsing failed");