(&mut self, max_bytes: usize)
| 146 | peer: self.peer_string(), |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | pub fn read_available(&mut self, max_bytes: usize) -> NetResult<Option<Vec<u8>>> { |
| 151 | let mut buf = vec![0_u8; max_bytes.max(1)]; |
| 152 | match self.stream.read(&mut buf) { |
| 153 | Ok(n) => { |
| 154 | buf.truncate(n); |
| 155 | Ok(Some(buf)) |
| 156 | } |
| 157 | Err(err) if err.kind() == io::ErrorKind::WouldBlock => Ok(None), |
| 158 | Err(err) => Err(NetError::from_io(NetErrorKind::Receive, err)), |
| 159 | } |
| 160 | } |
nothing calls this directly
no test coverage detected