Struct trust_dns::serialize::binary::BinDecoder
[−]
[src]
pub struct BinDecoder<'a> { /* fields omitted */ }
This is non-destructive to the inner buffer, b/c for pointer types we need to perform a reverse seek to lookup names
A note on serialization, there was a thought to have this implement the Serde deserializer, but given that this is such a small subset of all the serialization which that performs this is a simpler implementation without the cruft, at least for serializing to/from the binary DNS protocols.
Methods
impl<'a> BinDecoder<'a>
[src]
fn new(buffer: &'a [u8]) -> Self
fn pop(&mut self) -> DecodeResult<u8>
Pop one byte from the buffer
fn len(&self) -> usize
Returns the number of bytes in the buffer
fn peek(&self) -> Option<u8>
Peed one byte forward, without moving the current index forward
fn index(&self) -> usize
Returns the current index in the buffer
fn clone(&self, index_at: u16) -> BinDecoder
This is a pretty efficient clone, as the buffer is never cloned, and only the index is set to the value passed in
fn read_character_data(&mut self) -> DecodeResult<String>
Reads a String from the buffer
<character-string> is a single
length octet followed by that number of characters. <character-string>
is treated as binary information, and can be up to 256 characters in
length (including the length octet).
Returns
A String version of the character data
fn read_vec(&mut self, len: usize) -> DecodeResult<Vec<u8>>
Reads a Vec out of the buffer
Arguments
len
- number of bytes to read from the buffer
Returns
The Vec of the specified length, otherwise an error
fn read_u8(&mut self) -> DecodeResult<u8>
Reads a byte from the buffer, equivalent to Self::pop()
fn read_u16(&mut self) -> DecodeResult<u16>
Reads the next 2 bytes into u16
This performs a byte-by-byte manipulation, there which means endianness is implicitly handled (i.e. no network to little endian (intel), issues)
Return
Return the u16 from the buffer
fn read_i32(&mut self) -> DecodeResult<i32>
Reads the next four bytes into i32.
This performs a byte-by-byte manipulation, there which means endianness is implicitly handled (i.e. no network to little endian (intel), issues)
Return
Return the i32 from the buffer
fn read_u32(&mut self) -> DecodeResult<u32>
Reads the next four bytes into u32.
This performs a byte-by-byte manipulation, there which means endianness is implicitly handled (i.e. no network to little endian (intel), issues)
Return
Return the u32 from the buffer