diff options
Diffstat (limited to 'tokio-net/src/udp/socket.rs')
-rw-r--r-- | tokio-net/src/udp/socket.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/tokio-net/src/udp/socket.rs b/tokio-net/src/udp/socket.rs index c59b564b..90f212a2 100644 --- a/tokio-net/src/udp/socket.rs +++ b/tokio-net/src/udp/socket.rs @@ -108,7 +108,7 @@ impl UdpSocket { /// /// [`connect`]: #method.connect pub async fn send(&mut self, buf: &[u8]) -> io::Result<usize> { - poll_fn(|cx| self.poll_send_priv(cx, buf)).await + poll_fn(|cx| self.poll_send(cx, buf)).await } // Poll IO functions that takes `&self` are provided for the split API. @@ -121,11 +121,8 @@ impl UdpSocket { // While violating this requirement is "safe" from a Rust memory model point // of view, it will result in unexpected behavior in the form of lost // notifications and tasks hanging. - pub(crate) fn poll_send_priv( - &self, - cx: &mut Context<'_>, - buf: &[u8], - ) -> Poll<io::Result<usize>> { + #[doc(hidden)] + pub fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<io::Result<usize>> { ready!(self.io.poll_write_ready(cx))?; match self.io.get_ref().send(buf) { @@ -150,14 +147,11 @@ impl UdpSocket { /// /// [`connect`]: #method.connect pub async fn recv(&mut self, buf: &mut [u8]) -> io::Result<usize> { - poll_fn(|cx| self.poll_recv_priv(cx, buf)).await + poll_fn(|cx| self.poll_recv(cx, buf)).await } - pub(crate) fn poll_recv_priv( - &self, - cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll<io::Result<usize>> { + #[doc(hidden)] + pub fn poll_recv(&self, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<io::Result<usize>> { ready!(self.io.poll_read_ready(cx, mio::Ready::readable()))?; match self.io.get_ref().recv(buf) { @@ -178,7 +172,7 @@ impl UdpSocket { let mut addrs = target.to_socket_addrs().await?; match addrs.next() { - Some(target) => poll_fn(|cx| self.poll_send_to_priv(cx, buf, &target)).await, + Some(target) => poll_fn(|cx| self.poll_send_to(cx, buf, &target)).await, None => Err(io::Error::new( io::ErrorKind::InvalidInput, "no addresses to send data to", @@ -186,7 +180,9 @@ impl UdpSocket { } } - pub(crate) fn poll_send_to_priv( + // TODO: Public or not? + #[doc(hidden)] + pub fn poll_send_to( &self, cx: &mut Context<'_>, buf: &[u8], @@ -210,10 +206,11 @@ impl UdpSocket { /// to hold the message bytes. If a message is too long to fit in the supplied /// buffer, excess bytes may be discarded. pub async fn recv_from(&mut self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - poll_fn(|cx| self.poll_recv_from_priv(cx, buf)).await + poll_fn(|cx| self.poll_recv_from(cx, buf)).await } - pub(crate) fn poll_recv_from_priv( + #[doc(hidden)] + pub fn poll_recv_from( &self, cx: &mut Context<'_>, buf: &mut [u8], |