diff --git a/src/lib.rs b/src/lib.rs index cf9f6d7..2d300f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -425,26 +425,31 @@ impl> IntoUdpSocket { +pub trait Udp { + type Error; + fn receive( &mut self, target_buffer: &mut [u8], - ) -> Result, TransferError>; + ) -> Result, Self::Error>; + fn blocking_send( &mut self, host: &IpAddress, host_port: u16, data: &[u8], - ) -> Result<(), TransferError>; + ) -> Result<(), Self::Error>; } -impl> Udp +impl> Udp for (&mut ActiveW5500<'_, '_, '_, ChipSelect, Spi>, &UdpSocket) { + type Error = TransferError; + fn receive( &mut self, destination: &mut [u8], - ) -> Result, TransferError> { + ) -> Result, Self::Error> { let (w5500, UdpSocket(socket)) = self; if w5500.read_u8(socket.at(SocketRegister::InterruptMask))? & 0x04 == 0 { @@ -500,7 +505,7 @@ impl> Udp Result<(), TransferError> { + ) -> Result<(), Self::Error> { let (w5500, UdpSocket(socket)) = self; {