pub struct Decoder { /* private fields */ }Expand description
BER decoder that reads from a byte buffer.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn from_slice(data: &[u8]) -> Self
pub fn from_slice(data: &[u8]) -> Self
Create a decoder from a byte slice (copies the data).
Sourcepub fn read_length(&mut self) -> Result<usize>
pub fn read_length(&mut self) -> Result<usize>
Read a length and return (length, bytes consumed).
Sourcepub fn read_bytes(&mut self, len: usize) -> Result<Bytes>
pub fn read_bytes(&mut self, len: usize) -> Result<Bytes>
Read raw bytes without copying.
Sourcepub fn expect_tag(&mut self, expected: u8) -> Result<usize>
pub fn expect_tag(&mut self, expected: u8) -> Result<usize>
Read and expect a specific tag, returning the content length.
Sourcepub fn read_integer(&mut self) -> Result<i32>
pub fn read_integer(&mut self) -> Result<i32>
Read a BER integer (signed).
Sourcepub fn read_integer_value(&mut self, len: usize) -> Result<i32>
pub fn read_integer_value(&mut self, len: usize) -> Result<i32>
Read integer value given the length.
Sourcepub fn read_integer64(&mut self, expected_tag: u8) -> Result<u64>
pub fn read_integer64(&mut self, expected_tag: u8) -> Result<u64>
Read a 64-bit unsigned integer (Counter64).
Sourcepub fn read_integer64_value(&mut self, len: usize) -> Result<u64>
pub fn read_integer64_value(&mut self, len: usize) -> Result<u64>
Read 64-bit unsigned integer value given the length.
Sourcepub fn read_unsigned32(&mut self, expected_tag: u8) -> Result<u32>
pub fn read_unsigned32(&mut self, expected_tag: u8) -> Result<u32>
Read an unsigned 32-bit integer with specific tag.
Sourcepub fn read_unsigned32_value(&mut self, len: usize) -> Result<u32>
pub fn read_unsigned32_value(&mut self, len: usize) -> Result<u32>
Read unsigned 32-bit integer value given length.
Sourcepub fn read_octet_string(&mut self) -> Result<Bytes>
pub fn read_octet_string(&mut self) -> Result<Bytes>
Read an OCTET STRING.
Sourcepub fn read_oid_value(&mut self, len: usize) -> Result<Oid>
pub fn read_oid_value(&mut self, len: usize) -> Result<Oid>
Read an OID given a pre-read length.
Sourcepub fn read_sequence(&mut self) -> Result<Decoder>
pub fn read_sequence(&mut self) -> Result<Decoder>
Read a SEQUENCE, returning a decoder for its contents.
Sourcepub fn read_constructed(&mut self, expected_tag: u8) -> Result<Decoder>
pub fn read_constructed(&mut self, expected_tag: u8) -> Result<Decoder>
Read a constructed type with a specific tag, returning a decoder for its contents.
Sourcepub fn read_ip_address(&mut self) -> Result<[u8; 4]>
pub fn read_ip_address(&mut self) -> Result<[u8; 4]>
Read an IP address.
Sourcepub fn sub_decoder(&mut self, len: usize) -> Result<Decoder>
pub fn sub_decoder(&mut self, len: usize) -> Result<Decoder>
Create a sub-decoder for a portion of the remaining data.
Sourcepub fn remaining_slice(&self) -> &[u8] ⓘ
pub fn remaining_slice(&self) -> &[u8] ⓘ
Get remaining data as a slice.