Skip to main content

DerDecoder

Struct DerDecoder 

Source
pub struct DerDecoder<'a> { /* private fields */ }
Expand description

DER decoder: reads TLV items from a byte slice.

Implementations§

Source§

impl<'a> DerDecoder<'a>

Source

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

Create a decoder over a byte slice.

Source

pub fn remaining(&self) -> usize

Bytes remaining.

Source

pub fn is_empty(&self) -> bool

True if all bytes consumed.

Source

pub fn peek_tag(&self) -> Option<u8>

Peek at the next tag byte without advancing.

Source

pub fn read_tlv(&mut self) -> Option<(u8, &'a [u8])>

Read tag + length, return (tag, content_slice).

Source

pub fn read_sequence(&mut self) -> Option<DerDecoder<'a>>

Read a SEQUENCE, return a sub-decoder over its content.

Source

pub fn read_integer(&mut self) -> Option<&'a [u8]>

Read an INTEGER, return the big-endian unsigned bytes (leading zero stripped).

Source

pub fn read_integer_u64(&mut self) -> Option<u64>

Read an INTEGER as u64 (small values like version fields).

Source

pub fn read_octet_string(&mut self) -> Option<&'a [u8]>

Read an OCTET STRING.

Source

pub fn read_bit_string(&mut self) -> Option<&'a [u8]>

Read a BIT STRING, return the data bytes (skip unused-bits byte).

Source

pub fn read_oid(&mut self) -> Option<&'a [u8]>

Read an OID, return the encoded bytes.

Source

pub fn read_null(&mut self) -> Option<()>

Read a NULL.

Source

pub fn read_context_explicit(&mut self, tag_num: u8) -> Option<DerDecoder<'a>>

Read an explicit context-tagged [N] CONSTRUCTED, return a sub-decoder over its content. Returns None if the tag number doesn’t match or the tag is absent.

Source

pub fn skip(&mut self) -> Option<()>

Skip the next TLV element (any tag).

Auto Trait Implementations§

§

impl<'a> Freeze for DerDecoder<'a>

§

impl<'a> RefUnwindSafe for DerDecoder<'a>

§

impl<'a> Send for DerDecoder<'a>

§

impl<'a> Sync for DerDecoder<'a>

§

impl<'a> Unpin for DerDecoder<'a>

§

impl<'a> UnsafeUnpin for DerDecoder<'a>

§

impl<'a> UnwindSafe for DerDecoder<'a>

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<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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.