Changed UdpSocket to store a socket reference
This commit is contained in:
parent
bd78b82b8e
commit
715cdea318
2 changed files with 11 additions and 8 deletions
|
|
@ -1,12 +1,12 @@
|
|||
use crate::socket::Socket;
|
||||
|
||||
pub struct UdpSocket<SocketImpl: Socket> {
|
||||
socket: SocketImpl,
|
||||
pub struct UdpSocket<'a, SocketImpl: Socket> {
|
||||
socket: &'a mut SocketImpl,
|
||||
}
|
||||
|
||||
impl<SocketImpl: Socket> UdpSocket<SocketImpl> {
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ impl<SpiBus: ActiveBus, NetworkImpl: Network> W5500<SpiBus, NetworkImpl> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn open_udp_socket<SocketImpl: Socket>(&self, socket: SocketImpl) -> UdpSocket<SocketImpl> {
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue