pub fn parse_ber<'a, T, F>(buf: &'a [u8], callback: F) -> ASN1Result<T>
Expand description
Parses BER-encoded data.
This function uses the loan pattern: callback
is called back with
a BERReader
, from which the ASN.1 value is read.
If you want to accept only DER-encoded data, use parse_der
.
§Examples
use yasna;
let data = &[48, 128, 2, 1, 10, 1, 1, 255, 0, 0];
let asn = yasna::parse_ber(data, |reader| {
reader.read_sequence(|reader| {
let i = reader.next().read_i64()?;
let b = reader.next().read_bool()?;
return Ok((i, b));
})
}).unwrap();
println!("{:?} = [48, 128, 2, 1, 10, 1, 1, 255, 0, 0]", asn);