Laid out concept for UdpSocket init
This commit is contained in:
parent
b30e4d0d34
commit
e8c8e3c9cc
3 changed files with 12 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
|||
pub trait Socket {}
|
||||
pub trait Socket {
|
||||
// TODO expose method to get address of socket
|
||||
}
|
||||
|
||||
pub type OwnedSockets = (
|
||||
Socket0,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
use crate::socket::Socket;
|
||||
|
||||
pub struct UdpSocket<SocketImpl: Socket> {
|
||||
pub socket: SocketImpl,
|
||||
socket: SocketImpl,
|
||||
}
|
||||
|
||||
impl<SocketImpl: Socket> UdpSocket<SocketImpl> {
|
||||
pub fn new(socket: SocketImpl) -> Self {
|
||||
// TODO initialize socket for UDP mode
|
||||
UdpSocket { socket }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl<SpiBus: ActiveBus, NetworkImpl: Network> W5500<SpiBus, NetworkImpl> {
|
|||
}
|
||||
|
||||
pub fn open_udp_socket<SocketImpl: Socket>(&self, socket: SocketImpl) -> UdpSocket<SocketImpl> {
|
||||
UdpSocket { socket }
|
||||
UdpSocket::new(socket)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue