From 82a1c971ff931e4433a28d035ac647cde23ab834 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 11 Jun 2020 22:24:13 +0200 Subject: [PATCH] Document `Error::Finished` in `recv()`. --- src/socket/tcp.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/socket/tcp.rs b/src/socket/tcp.rs index b7b09913a..2974f9f89 100644 --- a/src/socket/tcp.rs +++ b/src/socket/tcp.rs @@ -742,8 +742,13 @@ impl<'a> TcpSocket<'a> { /// Call `f` with the largest contiguous slice of octets in the receive buffer, /// and dequeue the amount of elements returned by `f`. /// - /// This function returns `Err(Error::Illegal)` if the receive half of - /// the connection is not open; see [may_recv](#method.may_recv). + /// This function errors if the receive half of the connection is not open. + /// + /// If the receive half has been gracefully closed (with a FIN packet), `Err(Error::Finished)` + /// is returned. In this case, the previously received data is guaranteed to be complete. + /// + /// In all other cases, `Err(Error::Illegal)` is returned and previously received data (if any) + /// may be incomplete (truncated). pub fn recv<'b, F, R>(&'b mut self, f: F) -> Result where F: FnOnce(&'b mut [u8]) -> (usize, R) { self.recv_impl(|rx_buffer| {