(&self, cursor: &mut Cursor<&[u8]>)
| 346 | } |
| 347 | |
| 348 | async fn read_cstring(&self, cursor: &mut Cursor<&[u8]>) -> Result<String, ParseError> { |
| 349 | let mut bytes = Vec::new(); |
| 350 | loop { |
| 351 | if bytes.len() > self.max_string_length { |
| 352 | return Err(ParseError::ProtocolViolation("String too long".to_string())); |
| 353 | } |
| 354 | |
| 355 | let byte = cursor.read_u8()?; |
| 356 | if byte == 0 { |
| 357 | break; |
| 358 | } |
| 359 | bytes.push(byte); |
| 360 | } |
| 361 | |
| 362 | String::from_utf8(bytes).map_err(|_| ParseError::InvalidEncoding) |
| 363 | } |
| 364 | |
| 365 | async fn read_cstring_with_length(&self, cursor: &mut Cursor<&[u8]>, max_length: usize) -> Result<String, ParseError> { |
| 366 | let mut bytes = Vec::new(); |
no test coverage detected