Struct trust_dns::serialize::binary::BinDecoder [] [src]

pub struct BinDecoder<'a> {
    // some 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 rustc-serialization, 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. rustc-serialization will be used for other coms, e.g. json over http

Methods

impl<'a> BinDecoder<'a>

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

fn pop(&mut self) -> DecodeResult<u8>

fn len(&self) -> usize

fn peek(&self) -> Option<u8>

fn index(&self) -> usize

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>

is a single length octet followed by that number of characters. is treated as binary information, and can be up to 256 characters in length (including the length octet).

the vector should be reversed before calling.

fn read_vec(&mut self, len: usize) -> DecodeResult<Vec<u8>>

fn read_u8(&mut self) -> DecodeResult<u8>

fn read_u16(&mut self) -> DecodeResult<u16>

parses 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)

the vector should be reversed before calling.

fn read_i32(&mut self) -> DecodeResult<i32>

parses 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)

the vector should be reversed before calling.

fn read_u32(&mut self) -> DecodeResult<u32>

parses 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)

the vector should be reversed before calling.