(&mut self)
| 181 | } |
| 182 | |
| 183 | fn read_bytes(&mut self) -> crate::Result<Vec<u8>> { |
| 184 | let num_bytes = self.transport.read_i32::<BigEndian>()?; |
| 185 | |
| 186 | if num_bytes < 0 { |
| 187 | return Err(crate::Error::Protocol(ProtocolError::new( |
| 188 | ProtocolErrorKind::NegativeSize, |
| 189 | format!("Negative byte array size: {}", num_bytes), |
| 190 | ))); |
| 191 | } |
| 192 | |
| 193 | if let Some(max_size) = self.config.max_string_size() { |
| 194 | if num_bytes as usize > max_size { |
| 195 | return Err(crate::Error::Protocol(ProtocolError::new( |
| 196 | ProtocolErrorKind::SizeLimit, |
| 197 | format!( |
| 198 | "Byte array size {} exceeds maximum allowed size of {}", |
| 199 | num_bytes, max_size |
| 200 | ), |
| 201 | ))); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | let mut buf = vec![0u8; num_bytes as usize]; |
| 206 | self.transport |
| 207 | .read_exact(&mut buf) |
| 208 | .map(|_| buf) |
| 209 | .map_err(From::from) |
| 210 | } |
| 211 | |
| 212 | fn read_bool(&mut self) -> crate::Result<bool> { |
| 213 | let b = self.read_i8()?; |
no test coverage detected