pub struct MsgReader<'a> { /* private fields */ }
Expand description
Reads a single DNS message from a series of bytes.
Implementations§
Source§impl<'a> MsgReader<'a>
impl<'a> MsgReader<'a>
Sourcepub fn with_offset(data: &[u8], offset: usize) -> MsgReader<'_>
pub fn with_offset(data: &[u8], offset: usize) -> MsgReader<'_>
Constructs a new message reader, which will read from data
,
beginning at offset
.
Sourcepub fn read(&mut self, buf: &mut [u8]) -> Result<(), DecodeError>
pub fn read(&mut self, buf: &mut [u8]) -> Result<(), DecodeError>
Reads a number of bytes equal to the length of the given buffer.
Returns Err(ShortMessage)
if there are not enough bytes remaining.
Sourcepub fn read_byte(&mut self) -> Result<u8, DecodeError>
pub fn read_byte(&mut self) -> Result<u8, DecodeError>
Reads a single byte from the message.
Sourcepub fn read_to_end(&mut self) -> Result<Vec<u8>, DecodeError>
pub fn read_to_end(&mut self) -> Result<Vec<u8>, DecodeError>
Reads all remaining bytes.
Sourcepub fn read_character_string(&mut self) -> Result<Vec<u8>, DecodeError>
pub fn read_character_string(&mut self) -> Result<Vec<u8>, DecodeError>
Read a character-string.
According to RFC 1035:
is a single length octet followed by that number of characters. is treated as binary information, and can be up to 256 characters in length (including the length octet).
Sourcepub fn read_u16(&mut self) -> Result<u16, DecodeError>
pub fn read_u16(&mut self) -> Result<u16, DecodeError>
Reads a big-endian unsigned 16 bit integer.
Sourcepub fn read_u32(&mut self) -> Result<u32, DecodeError>
pub fn read_u32(&mut self) -> Result<u32, DecodeError>
Reads a big-endian unsigned 32 bit integer.
Sourcepub fn read_into(
&mut self,
buf: &mut Vec<u8>,
n: usize,
) -> Result<(), DecodeError>
pub fn read_into( &mut self, buf: &mut Vec<u8>, n: usize, ) -> Result<(), DecodeError>
Reads n
bytes, which are inserted at the end of the given buffer.
Sourcepub fn read_name(&mut self) -> Result<String, DecodeError>
pub fn read_name(&mut self) -> Result<String, DecodeError>
Reads a name from the message.
Auto Trait Implementations§
impl<'a> Freeze for MsgReader<'a>
impl<'a> RefUnwindSafe for MsgReader<'a>
impl<'a> Send for MsgReader<'a>
impl<'a> Sync for MsgReader<'a>
impl<'a> Unpin for MsgReader<'a>
impl<'a> UnwindSafe for MsgReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more