Struct dns_protocol::Message
source · [−]pub struct Message<'arrays, 'innards> { /* private fields */ }Expand description
The message for a DNS query.
Implementations
sourceimpl<'arrays, 'innards> Message<'arrays, 'innards>
impl<'arrays, 'innards> Message<'arrays, 'innards>
sourcepub fn new(
id: u16,
flags: Flags,
questions: &'arrays mut [Question<'innards>],
answers: &'arrays mut [ResourceRecord<'innards>],
authorities: &'arrays mut [ResourceRecord<'innards>],
additional: &'arrays mut [ResourceRecord<'innards>]
) -> Self
pub fn new(
id: u16,
flags: Flags,
questions: &'arrays mut [Question<'innards>],
answers: &'arrays mut [ResourceRecord<'innards>],
authorities: &'arrays mut [ResourceRecord<'innards>],
additional: &'arrays mut [ResourceRecord<'innards>]
) -> Self
Create a new message from a set of buffers for each section.
Panics
This function panics if the number of questions, answers, authorities, or additional records
is greater than u16::MAX.
sourcepub fn flags_mut(&mut self) -> &mut Flags
pub fn flags_mut(&mut self) -> &mut Flags
Get a mutable reference to the flags for this message.
sourcepub fn questions_mut(&mut self) -> &mut [Question<'innards>]
pub fn questions_mut(&mut self) -> &mut [Question<'innards>]
Get a mutable reference to the questions in this message.
sourcepub fn answers(&self) -> &[ResourceRecord<'innards>]
pub fn answers(&self) -> &[ResourceRecord<'innards>]
Get the answers in this message.
sourcepub fn answers_mut(&mut self) -> &mut [ResourceRecord<'innards>]
pub fn answers_mut(&mut self) -> &mut [ResourceRecord<'innards>]
Get a mutable reference to the answers in this message.
Get the authorities in this message.
Get a mutable reference to the authorities in this message.
sourcepub fn additional(&self) -> &[ResourceRecord<'innards>]
pub fn additional(&self) -> &[ResourceRecord<'innards>]
Get the additional records in this message.
sourcepub fn additional_mut(&mut self) -> &mut [ResourceRecord<'innards>]
pub fn additional_mut(&mut self) -> &mut [ResourceRecord<'innards>]
Get a mutable reference to the additional records in this message.
sourcepub fn space_needed(&self) -> usize
pub fn space_needed(&self) -> usize
Get the buffer space needed to serialize this message.
sourcepub fn write(&self, buffer: &mut [u8]) -> Result<usize, Error>
pub fn write(&self, buffer: &mut [u8]) -> Result<usize, Error>
Write this message to a buffer.
Returns the number of bytes written.
Errors
This function may raise Error::NameTooLong if a Label is too long to be serialized.
Panics
This function panics if the buffer is not large enough to hold the serialized message. This
panic can be avoided by ensuring the buffer contains at least [space_needed] bytes.
sourcepub fn read(
buffer: &'innards [u8],
questions: &'arrays mut [Question<'innards>],
answers: &'arrays mut [ResourceRecord<'innards>],
authorities: &'arrays mut [ResourceRecord<'innards>],
additional: &'arrays mut [ResourceRecord<'innards>]
) -> Result<Message<'arrays, 'innards>, Error>
pub fn read(
buffer: &'innards [u8],
questions: &'arrays mut [Question<'innards>],
answers: &'arrays mut [ResourceRecord<'innards>],
authorities: &'arrays mut [ResourceRecord<'innards>],
additional: &'arrays mut [ResourceRecord<'innards>]
) -> Result<Message<'arrays, 'innards>, Error>
Read a message from a buffer.
Errors
This function may raise one of the following errors:
Error::NotEnoughReadBytesif the buffer is not large enough to hold the entire structure. You may need to read more data before calling this function again.Error::NotEnoughWriteSpaceif the buffers provided are not large enough to hold the entire structure. You may need to allocate larger buffers before calling this function.Error::InvalidUtf8if a domain name contains invalid UTF-8.Error::NameTooLongif a domain name is too long to be deserialized.Error::InvalidCodeif a domain name contains an invalid label code.
Trait Implementations
sourceimpl<'arrays, 'innards> Ord for Message<'arrays, 'innards>
impl<'arrays, 'innards> Ord for Message<'arrays, 'innards>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl<'arrays, 'innards> PartialEq<Message<'arrays, 'innards>> for Message<'arrays, 'innards>
impl<'arrays, 'innards> PartialEq<Message<'arrays, 'innards>> for Message<'arrays, 'innards>
sourceimpl<'arrays, 'innards> PartialOrd<Message<'arrays, 'innards>> for Message<'arrays, 'innards>
impl<'arrays, 'innards> PartialOrd<Message<'arrays, 'innards>> for Message<'arrays, 'innards>
sourcefn partial_cmp(&self, other: &Message<'arrays, 'innards>) -> Option<Ordering>
fn partial_cmp(&self, other: &Message<'arrays, 'innards>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more