(mut bytes: Vec<u8>)
| 420 | } |
| 421 | |
| 422 | fn string_from_utf8(mut bytes: Vec<u8>) -> Option<String> { |
| 423 | // we'd truncate the raw bytes when sending |
| 424 | // so the last char may be incomplete |
| 425 | for _ in 0..4 { |
| 426 | match String::from_utf8(bytes) { |
| 427 | Ok(s) => return Some(s), |
| 428 | Err(e) => { |
| 429 | bytes = e.into_bytes(); |
| 430 | bytes.pop(); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | None |
| 435 | } |
no test coverage detected