Function yasna::parse_der [−][src]
pub fn parse_der<'a, T, F>(buf: &'a [u8], callback: F) -> ASN1Result<T> where
F: for<'b> FnOnce(BERReader<'a, 'b>) -> ASN1Result<T>,
Parses DER-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 parse BER-encoded data in general,
use parse_ber
.
Examples
use yasna; let data = &[48, 6, 2, 1, 10, 1, 1, 255]; let asn = yasna::parse_der(data, |reader| { reader.read_sequence(|reader| { let i = try!(reader.next().read_i64()); let b = try!(reader.next().read_bool()); return Ok((i, b)); }) }).unwrap(); println!("{:?} = [48, 6, 2, 1, 10, 1, 1, 255]", asn);