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

pub struct BinEncoder<'a> { /* fields omitted */ }

Encode DNS messages and resource record types.

Methods

impl<'a> BinEncoder<'a>
[src]

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.

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.

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']);