pub struct SmoltcpDevice { /* private fields */ }Expand description
smoltcp device backed by SharedState’s lock-free queues.
§Slot-based design
The poll loop controls when frames are popped from tx_ring:
- Call
stage_next_frame()to pop a frame and inspect it. - Optionally call
drop_staged_frame()to discard the frame (e.g. non-DNS UDP handled outside smoltcp). - When smoltcp’s
iface.poll()callsreceive(), the staged frame is consumed.
Implementations§
Source§impl SmoltcpDevice
impl SmoltcpDevice
Sourcepub fn new(shared: Arc<SharedState>, mtu: usize) -> Self
pub fn new(shared: Arc<SharedState>, mtu: usize) -> Self
Create a new device connected to the given shared state.
mtu is the IP-level MTU (e.g. 1500). The Ethernet frame MTU reported
to smoltcp is mtu + 14 (Ethernet header).
Sourcepub fn stage_next_frame(&mut self) -> Option<&[u8]>
pub fn stage_next_frame(&mut self) -> Option<&[u8]>
Pop the next frame from tx_ring into the slot for inspection.
Called by the poll loop before iface.poll(). Returns a reference
to the staged frame, or None if the queue is empty. Repeated calls
return the same frame until it is consumed or dropped.
Sourcepub fn drop_staged_frame(&mut self)
pub fn drop_staged_frame(&mut self)
Discard the staged frame without letting smoltcp process it.
Used for frames handled outside smoltcp (e.g. non-DNS UDP relay).
Trait Implementations§
Source§impl Device for SmoltcpDevice
impl Device for SmoltcpDevice
type RxToken<'a> = SmoltcpRxToken
type TxToken<'a> = SmoltcpTxToken<'a>
Source§fn receive(
&mut self,
_timestamp: Instant,
) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>
fn receive( &mut self, _timestamp: Instant, ) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>
Construct a token pair consisting of one receive token and one transmit token. Read more
Source§fn transmit(&mut self, _timestamp: Instant) -> Option<Self::TxToken<'_>>
fn transmit(&mut self, _timestamp: Instant) -> Option<Self::TxToken<'_>>
Construct a transmit token. Read more
Source§fn capabilities(&self) -> DeviceCapabilities
fn capabilities(&self) -> DeviceCapabilities
Get a description of device capabilities.
Auto Trait Implementations§
impl !Freeze for SmoltcpDevice
impl RefUnwindSafe for SmoltcpDevice
impl Send for SmoltcpDevice
impl Sync for SmoltcpDevice
impl Unpin for SmoltcpDevice
impl UnsafeUnpin for SmoltcpDevice
impl UnwindSafe for SmoltcpDevice
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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