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, 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

Sets the maximum size of the buffer

DNS message lens must be smaller than u16::max_value due to hard limits in the protocol

this method will move to the constructor in a future release

Important traits for Vec<u8>

Returns a reference to the internal buffer

Returns the length of the buffer

Returns true if the buffer is empty

Returns the current offset into the buffer

sets the current offset to the new offset

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 additional length in the internal buffer.

trims to the current offset

Important traits for &'a [u8]

borrow a slice from the encoder

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

Emit one byte into the buffer

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

Emit one byte into the buffer

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

Emits all the elements of an Iterator to the encoder

Emits all the elements of an Iterator to the encoder

emits all items in the iterator, return the number emited

capture a location to write back to

calculates the length of data written since the place was creating

write back to a previously captured location

Auto Trait Implementations

impl<'a> Send for BinEncoder<'a>

impl<'a> Sync for BinEncoder<'a>