embassy-net/read document return value Ok(0)

This commit is contained in:
dvdsk 2024-08-23 15:04:00 +02:00
parent 423e5d7655
commit acc26a076a
No known key found for this signature in database
GPG Key ID: F687E89FC7894F98

View File

@ -79,6 +79,9 @@ impl<'a> TcpReader<'a> {
/// ///
/// Returns how many bytes were read, or an error. If no data is available, it waits /// Returns how many bytes were read, or an error. If no data is available, it waits
/// until there is at least one byte available. /// until there is at least one byte available.
///
/// A return value of Ok(0) means that the socket was closed and is longer able to
/// accept bytes or that the buffer provided is empty.
pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> { pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.io.read(buf).await self.io.read(buf).await
} }
@ -273,6 +276,9 @@ impl<'a> TcpSocket<'a> {
/// ///
/// Returns how many bytes were read, or an error. If no data is available, it waits /// Returns how many bytes were read, or an error. If no data is available, it waits
/// until there is at least one byte available. /// until there is at least one byte available.
///
/// A return value of Ok(0) means that the socket was closed and is longer able to
/// accept bytes or that the buffer provided is empty.
pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> { pub async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
self.io.read(buf).await self.io.read(buf).await
} }