Struct MsgReader

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

Reads a single DNS message from a series of bytes.

Implementations§

Source§

impl<'a> MsgReader<'a>

Source

pub fn new(data: &[u8]) -> MsgReader<'_>

Constructs a new message reader.

Source

pub fn with_offset(data: &[u8], offset: usize) -> MsgReader<'_>

Constructs a new message reader, which will read from data, beginning at offset.

Source

pub fn remaining(&self) -> usize

Returns the number of bytes remaining in the message.

Source

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.

Source

pub fn read_byte(&mut self) -> Result<u8, DecodeError>

Reads a single byte from the message.

Source

pub fn read_to_end(&mut self) -> Result<Vec<u8>, DecodeError>

Reads all remaining bytes.

Source

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).

Source

pub fn read_u16(&mut self) -> Result<u16, DecodeError>

Reads a big-endian unsigned 16 bit integer.

Source

pub fn read_u32(&mut self) -> Result<u32, DecodeError>

Reads a big-endian unsigned 32 bit integer.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V