Skip to main content

BerReader

Struct BerReader 

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

Zero-copy BER decoder over a byte slice.

Implementations§

Source§

impl<'a> BerReader<'a>

Source

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

Source

pub fn with_max_depth(self, max: u16) -> Self

Source

pub fn with_max_element_size(self, max: u32) -> Self

Source

pub fn is_empty(&self) -> bool

Source

pub fn remaining(&self) -> &'a [u8]

Source

pub fn peek_tag(&self) -> Result<Tag, BerError>

Peek at the tag of the next element without consuming it.

Source

pub fn read_element(&mut self) -> Result<(Tag, &'a [u8]), BerError>

Read the next TLV element, returning (tag, value_bytes).

Source

pub fn read_sequence<F, T>( &mut self, expected_tag: Tag, f: F, ) -> Result<T, BerError>
where F: FnOnce(&mut BerReader<'_>) -> Result<T, BerError>,

Read a constructed element (SEQUENCE, SET, or context-tagged), passing a sub-reader scoped to its contents.

Source

pub fn read_sequence_lax<F, T>( &mut self, expected_tag: Tag, f: F, ) -> Result<T, BerError>
where F: FnOnce(&mut BerReader<'_>) -> Result<T, BerError>,

Like read_sequence but allows trailing data in the constructed element.

Source

pub fn read_integer(&mut self) -> Result<i64, BerError>

Source

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

Source

pub fn read_boolean(&mut self) -> Result<bool, BerError>

Source

pub fn read_enumerated(&mut self) -> Result<i64, BerError>

Source

pub fn read_tagged_value(&mut self) -> Result<(Tag, &'a [u8]), BerError>

Read an element with any tag, returning its raw bytes.

Source

pub fn read_tagged_implicit_octet_string( &mut self, expected_number: u32, ) -> Result<&'a [u8], BerError>

Read a tagged implicit octet string (context-tagged primitive).

Auto Trait Implementations§

§

impl<'a> Freeze for BerReader<'a>

§

impl<'a> RefUnwindSafe for BerReader<'a>

§

impl<'a> Send for BerReader<'a>

§

impl<'a> Sync for BerReader<'a>

§

impl<'a> Unpin for BerReader<'a>

§

impl<'a> UnsafeUnpin for BerReader<'a>

§

impl<'a> UnwindSafe for BerReader<'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.