(reader: &mut Reader, len: usize)
| 771 | |
| 772 | #[inline] |
| 773 | pub fn read_utf8_standard(reader: &mut Reader, len: usize) -> Result<String, Error> { |
| 774 | let slice = reader.sub_slice(reader.get_cursor(), reader.get_cursor() + len)?; |
| 775 | // Rust is the only runtime that checks UTF-8 string payloads by default; borrow first so |
| 776 | // the check adds no temporary Vec before constructing the final String. |
| 777 | let value = std::str::from_utf8(slice) |
| 778 | .map_err(|_| Error::encoding_error("invalid UTF-8 string"))? |
| 779 | .to_owned(); |
| 780 | reader.move_next(len); |
| 781 | Ok(value) |
| 782 | } |
| 783 | |
| 784 | #[inline] |
| 785 | pub fn read_utf16_standard(reader: &mut Reader, len: usize) -> Result<String, Error> { |
nothing calls this directly
no test coverage detected