logo
pub struct SequenceIterator<'a, T, F> where
    F: ASN1Parser, 
{ /* private fields */ }
Available on crate feature mtls only.
Expand description

An Iterator over binary data, parsing elements of type T

This helps parsing SEQUENCE OF items of type T. The type of parser (BER/DER) is specified using the generic parameter F of this struct.

Note: the iterator must start on the sequence contents, not the sequence itself.

Examples

use asn1_rs::{DerParser, Integer, SequenceIterator};

let data = &[0x30, 0x6, 0x2, 0x1, 0x1, 0x2, 0x1, 0x2];
for (idx, item) in SequenceIterator::<Integer, DerParser>::new(&data[2..]).enumerate() {
    let item = item.unwrap(); // parsing could have failed
    let i = item.as_u32().unwrap(); // integer can be negative, or too large to fit into u32
    assert_eq!(i as usize, idx + 1);
}

Implementations

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.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Converts self into a collection.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Choose one element at random from the iterator. Read more

Choose one element at random from the iterator. Read more

Collects values at random from the iterator into a supplied buffer until that buffer is filled. Read more

Collects amount values at random from the iterator into a vector. Read more

Should always be Self

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more