Struct yasna::BERReaderSeq [−][src]
A reader object for a sequence of BER/DER-encoded ASN.1 data.
The main source of this object is the read_sequence
method from
BERReader
.
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(); assert_eq!(asn, (10, true));
Implementations
impl<'a, 'b> BERReaderSeq<'a, 'b>
[src]
pub fn mode(&self) -> BERMode
[src]
Tells which format we are parsing, BER or DER.
pub fn next<'c>(&'c mut self) -> BERReader<'a, 'c>
[src]
Generates a new BERReader
.
pub fn read_optional<T, F>(&mut self, callback: F) -> ASN1Result<Option<T>> where
F: for<'c> FnOnce(BERReader<'a, 'c>) -> ASN1Result<T>,
[src]
F: for<'c> FnOnce(BERReader<'a, 'c>) -> ASN1Result<T>,
Tries to read an ASN.1 value. If it fails at the first tag,
it doesn’t consume buffer and returns None
.
Used to parse OPTIONAL elements.
Examples
use yasna; let data = &[48, 3, 1, 1, 255]; let asn = yasna::parse_der(data, |reader| { reader.read_sequence(|reader| { let i = try!(reader.read_optional(|reader| { reader.read_i64() })); let b = try!(reader.next().read_bool()); return Ok((i, b)); }) }).unwrap(); assert_eq!(asn, (None, true));
pub fn read_default<T, F>(&mut self, default: T, callback: F) -> ASN1Result<T> where
F: for<'c> FnOnce(BERReader<'a, 'c>) -> ASN1Result<T>,
T: Eq,
[src]
F: for<'c> FnOnce(BERReader<'a, 'c>) -> ASN1Result<T>,
T: Eq,
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; let data = &[48, 3, 1, 1, 255]; let asn = yasna::parse_der(data, |reader| { reader.read_sequence(|reader| { let i = try!(reader.read_default(10, |reader| { reader.read_i64() })); let b = try!(reader.next().read_bool()); return Ok((i, b)); }) }).unwrap(); assert_eq!(asn, (10, true));
pub fn read_with_buffer<T, F>(
&mut self,
callback: F
) -> ASN1Result<(T, &'a [u8])> where
F: for<'c> FnOnce(&mut BERReaderSeq<'a, 'c>) -> ASN1Result<T>,
[src]
&mut self,
callback: F
) -> ASN1Result<(T, &'a [u8])> where
F: for<'c> FnOnce(&mut BERReaderSeq<'a, 'c>) -> ASN1Result<T>,
Trait Implementations
impl<'a, 'b> Debug for BERReaderSeq<'a, 'b> where
'a: 'b,
[src]
'a: 'b,
Auto Trait Implementations
impl<'a, 'b> RefUnwindSafe for BERReaderSeq<'a, 'b>
impl<'a, 'b> Send for BERReaderSeq<'a, 'b>
impl<'a, 'b> Sync for BERReaderSeq<'a, 'b>
impl<'a, 'b> Unpin for BERReaderSeq<'a, 'b> where
'a: 'b,
'a: 'b,
impl<'a, 'b> !UnwindSafe for BERReaderSeq<'a, 'b>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,