From 1b2ba0bfabaa6b355dc14ea54d60e267c5d73314 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Fri, 17 Feb 2023 17:51:20 +0200 Subject: [PATCH] feat: export uninitialized_device & add docs Signed-off-by: Lachezar Lechev --- src/lib.rs | 2 +- src/udp.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8f9dc5e..ac237a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ pub mod register; mod socket; pub mod tcp; pub mod udp; -mod uninitialized_device; +pub mod uninitialized_device; pub use device::{Device, DeviceRefMut, InactiveDevice}; pub use host::{Dhcp, Host, HostConfig, Manual}; diff --git a/src/udp.rs b/src/udp.rs index 3e29388..7566f16 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -78,6 +78,7 @@ impl UdpSocket { } } + /// Sets a new destination before performing the send operation. fn send_to( &mut self, bus: &mut SpiBus, @@ -88,6 +89,9 @@ impl UdpSocket { self.send(bus, send_buffer) } + /// Receive data and mutate the `receive_buffer`. + /// + /// If [`Interrupt::Receive`] is not set, it will always return [`NbError::WouldBlock`]. fn receive( &mut self, bus: &mut SpiBus, @@ -139,6 +143,12 @@ impl UdpSocket { self.socket.command(bus, socketn::Command::Close)?; Ok(()) } + + /// returns the index of the socket + #[inline] + pub fn index(&self) -> u8 { + self.socket.index + } } #[derive(Debug)]