pub struct BinDecoder<'a> { /* fields omitted */ }
This is non-destructive to the inner buffer, b/c for pointer types we need to perform a reverse
seek to lookup names
A note on serialization, there was a thought to have this implement the Serde deserializer,
but given that this is such a small subset of all the serialization which that performs
this is a simpler implementation without the cruft, at least for serializing to/from the
binary DNS protocols.
Creates a new BinDecoder
buffer
- buffer from which all data will be read
Pop one byte from the buffer
Returns the number of bytes in the buffer
use trust_dns_proto::serialize::binary::BinDecoder;
let deadbeef = b"deadbeef";
let mut decoder = BinDecoder::new(deadbeef);
assert_eq!(decoder.len(), 8);
decoder.read_slice(7).unwrap();
assert_eq!(decoder.len(), 1);
Returns true
if the buffer is empty
Peed one byte forward, without moving the current index forward
Returns the current index in the buffer
This is a pretty efficient clone, as the buffer is never cloned, and only the index is set
to the value passed in
Reads a String from the buffer
<character-string> is a single
length octet followed by that number of characters. <character-string>
is treated as binary information, and can be up to 256 characters in
length (including the length octet).
A String version of the character data
Reads to a maximum length of data, returns an error if this is exceeded
Reads a Vec out of the buffer
len
- number of bytes to read from the buffer
The Vec of the specified length, otherwise an error
Reads a slice out of the buffer, without allocating
len
- number of bytes to read from the buffer
The slice of the specified length, otherwise an error
Reads a slice from a previous index to the current
Reads a byte from the buffer, equivalent to Self::pop()
Reads the next 2 bytes into u16
This performs a byte-by-byte manipulation, there
which means endianness is implicitly handled (i.e. no network to little endian (intel), issues)
Return the u16 from the buffer
Reads the next four bytes into i32.
This performs a byte-by-byte manipulation, there
which means endianness is implicitly handled (i.e. no network to little endian (intel), issues)
Return the i32 from the buffer
Reads the next four bytes into u32.
This performs a byte-by-byte manipulation, there
which means endianness is implicitly handled (i.e. no network to little endian (intel), issues)
Return the u32 from the buffer
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)