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)]