Embassy
embassy-net

Crates

git

Versions

default

Flavors

Struct embassy_net::dns::Socket

source ·
pub struct Socket<'a> { /* private fields */ }
Expand description

A Domain Name System socket.

A UDP socket is bound to a specific endpoint, and owns transmit and receive packet buffers.

Implementations§

source§

impl<'a> Socket<'a>

source

pub fn new<Q>(servers: &[Address], queries: Q) -> Socket<'a>
where Q: Into<ManagedSlice<'a, Option<DnsQuery>>>,

Create a DNS socket.

§Panics

Panics if servers.len() > MAX_SERVER_COUNT

source

pub fn update_servers(&mut self, servers: &[Address])

Update the list of DNS servers, will replace all existing servers

§Panics

Panics if servers.len() > MAX_SERVER_COUNT

source

pub fn hop_limit(&self) -> Option<u8>

Return the time-to-live (IPv4) or hop limit (IPv6) value used in outgoing packets.

See also the set_hop_limit method

source

pub fn set_hop_limit(&mut self, hop_limit: Option<u8>)

Set the time-to-live (IPv4) or hop limit (IPv6) value used in outgoing packets.

A socket without an explicitly set hop limit value uses the default IANA recommended value (64).

§Panics

This function panics if a hop limit value of 0 is given. See RFC 1122 § 3.2.1.7.

source

pub fn start_query( &mut self, cx: &mut InterfaceInner, name: &str, query_type: Type ) -> Result<QueryHandle, StartQueryError>

Start a query.

name is specified in human-friendly format, such as "rust-lang.org". It accepts names both with and without trailing dot, and they’re treated the same (there’s no support for DNS search path).

source

pub fn start_query_raw( &mut self, cx: &mut InterfaceInner, raw_name: &[u8], query_type: Type, mdns: MulticastDns ) -> Result<QueryHandle, StartQueryError>

Start a query with a raw (wire-format) DNS name. b"\x09rust-lang\x03org\x00"

You probably want to use [start_query] instead.

source

pub fn get_query_result( &mut self, handle: QueryHandle ) -> Result<Vec<Address, smoltcp::::socket::dns::{impl#3}::get_query_result::{constant#0}>, GetQueryResultError>

Get the result of a query.

If the query is completed, the query slot is automatically freed.

§Panics

Panics if the QueryHandle corresponds to a free slot.

source

pub fn cancel_query(&mut self, handle: QueryHandle)

Cancels a query, freeing the slot.

§Panics

Panics if the QueryHandle corresponds to an already free slot.

source

pub fn register_query_waker(&mut self, handle: QueryHandle, waker: &Waker)

Assign a waker to a query slot

The waker will be woken when the query completes, either successfully or failed.

§Panics

Panics if the QueryHandle corresponds to an already free slot.

Trait Implementations§

source§

impl<'a> AnySocket<'a> for Socket<'a>

source§

fn upcast(self) -> Socket<'a>

source§

fn downcast<'c>(socket: &'c Socket<'a>) -> Option<&'c Socket<'a>>

source§

fn downcast_mut<'c>(socket: &'c mut Socket<'a>) -> Option<&'c mut Socket<'a>>

source§

impl<'a> Debug for Socket<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Socket<'a>

§

impl<'a> RefUnwindSafe for Socket<'a>

§

impl<'a> Send for Socket<'a>

§

impl<'a> Sync for Socket<'a>

§

impl<'a> Unpin for Socket<'a>

§

impl<'a> !UnwindSafe for Socket<'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>,

§

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>,

§

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.