Struct trust_dns::serialize::binary::BinEncoder
[−]
[src]
pub struct BinEncoder<'a> { // some fields omitted }
Encode DNS messages and resource record types.
Methods
impl<'a> BinEncoder<'a>
[src]
fn new(buf: &'a mut Vec<u8>) -> Self
fn with_offset(buf: &'a mut Vec<u8>, offset: u32) -> Self
offset is used mainly for pointers. If this encoder is starting at some point further in the sequence of bytes, for the proper offset of the pointer, the offset accounts for that by using the offset to add to the pointer location being written.
fn as_bytes(self) -> &'a Vec<u8>
fn len(&self) -> usize
fn offset(&self) -> u32
fn reserve(&mut self, extra: usize)
fn emit(&mut self, b: u8) -> EncodeResult
fn store_label_pointer(&mut self, labels: Vec<Rc<String>>)
store the label pointer, the location is the current position in the buffer implicitly, it is expected that the name will be written to the stream after this.
fn get_label_pointer(&self, labels: &[Rc<String>]) -> Option<u16>
fn emit_character_data(&mut self, char_data: &str) -> EncodeResult
matches description from above.
use trust_dns::serialize::binary::BinEncoder; let mut bytes: Vec<u8> = Vec::new(); { let mut encoder: BinEncoder = BinEncoder::new(&mut bytes); encoder.emit_character_data("abc"); } assert_eq!(bytes, vec![3,b'a',b'b',b'c']);