Skip to main content

DualStack

Struct DualStack 

Source
pub struct DualStack<'set, 'sockets> { /* private fields */ }
Expand description

A family-aware UdpIo over a v4 and/or v6 smoltcp UDP socket living in a shared SocketSet — the smoltcp transport (single- OR dual-stack), mirroring hick-embassy’s DualUdp.

The engine fans every multicast to BOTH groups, so each datagram must reach the socket of ITS OWN family rather than be enqueued on a mismatched one (which would panic or be silently dropped). try_send routes by the destination’s family and reports SendError::Unsupported for an absent family (the engine then confirms on the family it has); try_recv alternates the two sockets round-robin so a sustained backlog on one family cannot starve the other under the engine’s per-pump RX cap. For a SINGLE-stack node, leave the absent family’s handle None — the family-explicit replacement for naively pumping one raw socket.

pump borrows the SocketSet for the duration of one step; build a fresh DualStack each step (it is a thin view) with DualStack::new, e.g. engine.pump(now, &mut DualStack::new(sockets, Some(h4), Some(h6)), buf).

Implementations§

Source§

impl<'set, 'sockets> DualStack<'set, 'sockets>

Source

pub fn new( sockets: &'set mut SocketSet<'sockets>, v4: Option<SocketHandle>, v6: Option<SocketHandle>, ) -> Self

Build the transport view for one pump step over a v4 and/or v6 socket living in sockets. Pass None for an absent family on a single-stack node.

Trait Implementations§

Source§

impl UdpIo for DualStack<'_, '_>

Source§

fn try_recv(&mut self, buf: &mut [u8]) -> Option<RecvMeta>

Pull one queued datagram into buf, returning its metadata, or None when the receive queue is empty. Non-blocking.
Source§

fn try_send(&mut self, buf: &[u8], dst: SocketAddr) -> Result<(), SendError>

Enqueue one datagram for dst. Non-blocking; returns SendError::Busy when the transmit queue is full, or SendError::Unsupported when there is no socket / route for the datagram’s address family.

Auto Trait Implementations§

§

impl<'set, 'sockets> !UnwindSafe for DualStack<'set, 'sockets>

§

impl<'set, 'sockets> Freeze for DualStack<'set, 'sockets>

§

impl<'set, 'sockets> RefUnwindSafe for DualStack<'set, 'sockets>

§

impl<'set, 'sockets> Send for DualStack<'set, 'sockets>

§

impl<'set, 'sockets> Sync for DualStack<'set, 'sockets>

§

impl<'set, 'sockets> Unpin for DualStack<'set, 'sockets>

§

impl<'set, 'sockets> UnsafeUnpin for DualStack<'set, 'sockets>

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.