pub struct BinEncoder<'a> { /* private fields */ }
Expand description

Encode DNS messages and resource record types.

Implementations

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

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

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

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.