pub struct Message<'arrays, 'innards> { /* private fields */ }Expand description
The message for a DNS query.
Implementations§
Source§impl<'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>],
) -> Message<'arrays, 'innards>
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>], ) -> Message<'arrays, 'innards>
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§
Source§impl<'innards> Deserialize<'innards> for Message<'_, 'innards>
impl<'innards> Deserialize<'innards> for Message<'_, 'innards>
Source§impl<'arrays, 'innards> Ord for Message<'arrays, 'innards>
impl<'arrays, 'innards> Ord for Message<'arrays, 'innards>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'arrays, 'innards> PartialOrd for Message<'arrays, 'innards>
impl<'arrays, 'innards> PartialOrd for Message<'arrays, 'innards>
impl<'arrays, 'innards> Eq for Message<'arrays, 'innards>
impl<'arrays, 'innards> StructuralPartialEq for Message<'arrays, 'innards>
Auto Trait Implementations§
impl<'arrays, 'innards> Freeze for Message<'arrays, 'innards>
impl<'arrays, 'innards> RefUnwindSafe for Message<'arrays, 'innards>
impl<'arrays, 'innards> Send for Message<'arrays, 'innards>
impl<'arrays, 'innards> Sync for Message<'arrays, 'innards>
impl<'arrays, 'innards> Unpin for Message<'arrays, 'innards>
impl<'arrays, 'innards> !UnwindSafe for Message<'arrays, 'innards>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more