smoltcp::socket::dns

Struct 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: &[IpAddress], 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: &[IpAddress])

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 Context, 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 Context, 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<IpAddress, DNS_MAX_RESULT_COUNT>, 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 Self>

Source§

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

Source§

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

Source§

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

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§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.