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

Method read_utf8_string

rust/fory-core/src/buffer.rs:960–970  ·  view source on GitHub ↗
(&mut self, len: usize)

Source from the content-addressed store, hash-verified

958
959 #[inline(always)]
960 pub fn read_utf8_string(&mut self, len: usize) -> Result<String, Error> {
961 self.check_bound(len)?;
962 let src = &self.bf[self.cursor..self.cursor + len];
963 // Rust is the only runtime that checks UTF-8 string payloads by default; other runtimes
964 // preserve their platform replacement behavior for invalid byte sequences.
965 let string =
966 std::str::from_utf8(src).map_err(|_| Error::encoding_error("invalid UTF-8 string"))?;
967 let string = string.to_owned();
968 self.move_next(len);
969 Ok(string)
970 }
971
972 #[inline(always)]
973 pub fn read_utf8_string_unchecked(&mut self, len: usize) -> Result<String, Error> {

Callers 3

fory_read_dataMethod · 0.80
fory_read_dataMethod · 0.80

Calls 2

check_boundMethod · 0.80
move_nextMethod · 0.80

Tested by 2

fory_read_dataMethod · 0.64