From 715cdea318d04c57dea856e7b3eb1820139b6f49 Mon Sep 17 00:00:00 2001 From: Jonah Dahlquist Date: Tue, 13 Aug 2019 20:26:02 -0500 Subject: [PATCH] Changed UdpSocket to store a socket reference --- src/udp/mod.rs | 14 +++++++------- src/w5500.rs | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/udp/mod.rs b/src/udp/mod.rs index 48a245e..4e882ec 100644 --- a/src/udp/mod.rs +++ b/src/udp/mod.rs @@ -1,12 +1,12 @@ use crate::socket::Socket; -pub struct UdpSocket { - socket: SocketImpl, +pub struct UdpSocket<'a, SocketImpl: Socket> { + socket: &'a mut SocketImpl, } -impl UdpSocket { - pub fn new(socket: SocketImpl) -> Self { - // TODO initialize socket for UDP mode - UdpSocket { socket } - } +impl<'a, SocketImpl: Socket> UdpSocket<'a, SocketImpl> { + pub fn new(socket: &'a mut SocketImpl) -> Self { + // TODO initialize socket for UDP mode + UdpSocket { socket } + } } diff --git a/src/w5500.rs b/src/w5500.rs index 4bf2d95..d00ca6e 100644 --- a/src/w5500.rs +++ b/src/w5500.rs @@ -50,7 +50,10 @@ impl W5500 { Ok(()) } - pub fn open_udp_socket(&self, socket: SocketImpl) -> UdpSocket { + pub fn open_udp_socket<'a, SocketImpl: Socket>( + &self, + socket: &'a mut SocketImpl, + ) -> UdpSocket<'a, SocketImpl> { // TODO compare socket to sockets list UdpSocket::new(socket) }