MCPcopy Create free account
hub / github.com/apache/fory / read_utf8_standard

Function read_utf8_standard

rust/fory-core/src/util/string_util.rs:773–782  ·  view source on GitHub ↗
(reader: &mut Reader, len: usize)

Source from the content-addressed store, hash-verified

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> {

Callers

nothing calls this directly

Calls 3

sub_sliceMethod · 0.80
get_cursorMethod · 0.80
move_nextMethod · 0.80

Tested by

no test coverage detected