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]

[src]

Create a new encoder with the Vec to fill

[src]

Specify the mode for encoding

Arguments

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

[src]

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

[src]

Returns a reference to the internal buffer

[src]

Returns the length of the buffer

[src]

Returns true if the buffer is empty

[src]

Returns the current offset into the buffer

[src]

Returns the current Encoding mode

[src]

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

[src]

Returns true if then encoder is writing in canonical form

[src]

Reserve specified length in the internal buffer

[src]

Emit one byte into the buffer

[src]

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.

[src]

Looks up the index of an already written label

[src]

matches description from above.

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

[src]

Emit one byte into the buffer

[src]

Writes a u16 in network byte order to the buffer

[src]

Writes an i32 in network byte order to the buffer

[src]

Writes an u32 in network byte order to the buffer

[src]

Writes the byte slice to the stream