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;
|
use crate::socket::Socket;
|
||||||
|
|
||||||
pub struct UdpSocket<SocketImpl: Socket> {
|
pub struct UdpSocket<'a, SocketImpl: Socket> {
|
||||||
socket: SocketImpl,
|
socket: &'a mut SocketImpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SocketImpl: Socket> UdpSocket<SocketImpl> {
|
impl<'a, SocketImpl: Socket> UdpSocket<'a, SocketImpl> {
|
||||||
pub fn new(socket: SocketImpl) -> Self {
|
pub fn new(socket: &'a mut SocketImpl) -> Self {
|
||||||
// TODO initialize socket for UDP mode
|
// TODO initialize socket for UDP mode
|
||||||
UdpSocket { socket }
|
UdpSocket { socket }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,10 @@ impl<SpiBus: ActiveBus, NetworkImpl: Network> W5500<SpiBus, NetworkImpl> {
|
||||||
Ok(())
|
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
|
// TODO compare socket to sockets list
|
||||||
UdpSocket::new(socket)
|
UdpSocket::new(socket)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue