embassy-net

Crates

git

Versions

default

Flavors

embassy_net::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: &[Address], queries: Q) -> Socket<'a>
where Q: Into<ManagedSlice<'a, Option<DnsQuery>>>,

Create a DNS socket.

Truncates the server list 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

Truncates the server list 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>,

Source§

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

Source§

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.