Struct asn1_rs::SequenceIterator

source ·
pub struct SequenceIterator<'a, T, F, E = Error>
where F: ASN1Parser,
{ /* private fields */ }
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§

source§

impl<'a, T, F, E> SequenceIterator<'a, T, F, E>
where F: ASN1Parser,

source

pub fn new(data: &'a [u8]) -> Self

Trait Implementations§

source§

impl<'a, T: Debug, F, E: Debug> Debug for SequenceIterator<'a, T, F, E>
where F: ASN1Parser + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T, F, E> Freeze for SequenceIterator<'a, T, F, E>

§

impl<'a, T, F, E> RefUnwindSafe for SequenceIterator<'a, T, F, E>

§

impl<'a, T, F, E> Send for SequenceIterator<'a, T, F, E>
where T: Send, F: Send, E: Send,

§

impl<'a, T, F, E> Sync for SequenceIterator<'a, T, F, E>
where T: Sync, F: Sync, E: Sync,

§

impl<'a, T, F, E> Unpin for SequenceIterator<'a, T, F, E>
where T: Unpin, F: Unpin, E: Unpin,

§

impl<'a, T, F, E> UnwindSafe for SequenceIterator<'a, T, F, E>
where T: UnwindSafe, F: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<I> IntoIterator for I
where I: Iterator,

§

type Item = <I as Iterator>::Item

The type of the elements being iterated over.
§

type IntoIter = I

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> I

Creates an iterator from a value. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.