Skip to content

Commit 80f654e

Browse files
committed
async UDP: Fix lifetimes of send and receive functions
Elided lifetimes would have asked too little of the data / buffer references.
1 parent e94d16f commit 80f654e

File tree

1 file changed

+4
-4
lines changed
  • embedded-nal-async/src/stack

1 file changed

+4
-4
lines changed

embedded-nal-async/src/stack/udp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub trait ConnectedUdp {
3131
type Error: embedded_io::Error;
3232

3333
/// Send the provided data to the connected peer
34-
fn send(&mut self, data: &[u8]) -> Self::SendFuture<'_>;
34+
fn send<'a>(&'a mut self, data: &'a [u8]) -> Self::SendFuture<'a>;
3535
/// Return type of the [`.send()`] method
3636
type SendFuture<'a>: Future<Output = Result<(), Self::Error>> where Self: 'a;
3737

@@ -46,7 +46,7 @@ pub trait ConnectedUdp {
4646
/// This deviates from the sync/nb equivalent trait in that it describes the overflow behavior
4747
/// (a possibility not considered there). The name deviates from the original `receive()` to
4848
/// make room for a version that is more zero-copy friendly.
49-
fn receive_into(&mut self, buffer: &mut [u8]) -> Self::ReceiveIntoFuture<'_>;
49+
fn receive_into<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReceiveIntoFuture<'a>;
5050
/// Return type of the [`.receive_into()`] method
5151
type ReceiveIntoFuture<'a>: Future<Output = Result<usize, Self::Error>> where Self: 'a;
5252

@@ -96,7 +96,7 @@ pub trait UnconnectedUdp {
9696
/// receive time; these should be equal. This allows implementations of the trait to use a
9797
/// single kind of socket for both sockets bound to a single and sockets bound to multiple
9898
/// addresses.
99-
fn send(&mut self, local: SocketAddr, remote: SocketAddr, data: &[u8]) -> Self::SendFuture<'_>;
99+
fn send<'a>(&'a mut self, local: SocketAddr, remote: SocketAddr, data: &'a [u8]) -> Self::SendFuture<'a>;
100100
/// Return type of the [`.send()`] method
101101
type SendFuture<'a>: Future<Output = Result<(), Self::Error>> where Self: 'a;
102102

@@ -108,7 +108,7 @@ pub trait UnconnectedUdp {
108108
///
109109
/// The local and remote address are given, in that order, in the result along with the number
110110
/// of bytes.
111-
fn receive_into(&mut self, buffer: &mut [u8]) -> Self::ReceiveIntoFuture<'_>;
111+
fn receive_into<'a>(&'a mut self, buffer: &'a mut [u8]) -> Self::ReceiveIntoFuture<'a>;
112112
/// Return type of the [`.receive_into()`] method
113113
type ReceiveIntoFuture<'a>: Future<Output = Result<(usize, SocketAddr, SocketAddr), Self::Error>> where Self: 'a;
114114
}

0 commit comments

Comments
 (0)