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]

Create a new encoder with the Vec to fill

Specify the mode for encoding

Arguments

  • mode - In Signing mode, it canonical forms of all data are encoded, otherwise format matches the source form

Begins the encoder at the given offset

This is used 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.

Arguments

  • offset - index at which to start writing into the buffer

Returns a reference to the internal buffer

Returns the length of the buffer

Returns the current offset into the buffer

Returns the current Encoding mode

If set to true, then names will be written into the buffer in canonical form

Returns true if then encoder is writing in canonical form

Reserve specified length in the internal buffer

Emit one byte into the buffer

Stores a label pointer to an already written label

The location is the current position in the buffer implicitly, it is expected that the name will be written to the stream after the current index.

Looks up the index of an already written label

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

Writes a u16 in network byte order to the buffer

Writes an i32 in network byte order to the buffer

Writes an u32 in network byte order to the buffer

Writes the byte slice to the stream