pub struct DnsSocket { /* private fields */ }
Expand description
Represents a socket transmitting DNS messages.
Implementations§
Source§impl DnsSocket
impl DnsSocket
Sourcepub fn bind<A: ToSocketAddrs>(addr: A) -> Result<DnsSocket>
pub fn bind<A: ToSocketAddrs>(addr: A) -> Result<DnsSocket>
Returns a DnsSocket
, bound to the given address.
Sourcepub fn send_message<A: ToSocketAddrs>(
&self,
message: &Message<'_>,
addr: A,
) -> Result<(), Error>
pub fn send_message<A: ToSocketAddrs>( &self, message: &Message<'_>, addr: A, ) -> Result<(), Error>
Sends a message to the given address.
Sourcepub fn recv_from<'buf>(
&self,
buf: &'buf mut [u8],
) -> Result<(Message<'buf>, SocketAddr), Error>
pub fn recv_from<'buf>( &self, buf: &'buf mut [u8], ) -> Result<(Message<'buf>, SocketAddr), Error>
Receives a message, returning the address of the sender. The given buffer is used to store and parse message data.
The buffer should be exactly MESSAGE_LIMIT
bytes in length.
Sourcepub fn recv_message<'buf>(
&self,
addr: &SocketAddr,
buf: &'buf mut [u8],
) -> Result<Option<Message<'buf>>, Error>
pub fn recv_message<'buf>( &self, addr: &SocketAddr, buf: &'buf mut [u8], ) -> Result<Option<Message<'buf>>, Error>
Attempts to read a DNS message. The message will only be decoded if the
remote address matches addr
. If a packet is received from a non-matching
address, the message is not decoded and Ok(None)
is returned.
The buffer should be exactly MESSAGE_LIMIT
bytes in length.
Auto Trait Implementations§
impl Freeze for DnsSocket
impl RefUnwindSafe for DnsSocket
impl Send for DnsSocket
impl Sync for DnsSocket
impl Unpin for DnsSocket
impl UnwindSafe for DnsSocket
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