pub struct BERReaderSet<'a, 'b>where
    'a: 'b,
{ /* private fields */ }
Expand description

A reader object for a set of BER/DER-encoded ASN.1 data.

The main source of this object is the read_set method from BERReader.

Examples

use yasna;
use yasna::tags::{TAG_INTEGER,TAG_BOOLEAN};
let data = &[49, 6, 1, 1, 255, 2, 1, 10];
let asn = yasna::parse_der(data, |reader| {
    reader.read_set(|reader| {
        let i = try!(try!(reader.next(&[TAG_INTEGER])).read_i64());
        let b = try!(try!(reader.next(&[TAG_BOOLEAN])).read_bool());
        return Ok((i, b));
    })
}).unwrap();
assert_eq!(asn, (10, true));

Implementations

Tells which format we are parsing, BER or DER.

Generates a new BERReader.

This method needs tag_hint to determine the position of the data.

If there is a set element with a tag in tag_hint, reads an ASN.1 value from that element and returns Some(_). Otherwise, returns None.

Used to parse OPTIONAL elements.

Examples
use yasna;
use yasna::tags::*;
let data = &[49, 3, 1, 1, 255];
let asn = yasna::parse_der(data, |reader| {
    reader.read_set(|reader| {
        let i = try!(reader.read_optional(&[TAG_INTEGER], |reader| {
            reader.read_i64()
        }));
        let b = try!(try!(reader.next(&[TAG_BOOLEAN])).read_bool());
        return Ok((i, b));
    })
}).unwrap();
assert_eq!(asn, (None, true));

Similar to read_optional, but uses default if it fails.

T: Eq is required because it fails in DER mode if the read value is equal to default.

Used to parse DEFAULT elements.

Examples
use yasna;
use yasna::tags::*;
let data = &[49, 3, 1, 1, 255];
let asn = yasna::parse_der(data, |reader| {
    reader.read_set(|reader| {
        let i = try!(reader.read_default(&[TAG_INTEGER], 10, |reader| {
            reader.read_i64()
        }));
        let b = try!(try!(reader.next(&[TAG_BOOLEAN])).read_bool());
        return Ok((i, b));
    })
}).unwrap();
assert_eq!(asn, (10, true));

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.