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

Method fory_read_data

rust/fory-core/src/serializer/string.rs:44–68  ·  view source on GitHub ↗
(context: &mut ReadContext)

Source from the content-addressed store, hash-verified

42
43 #[inline(always)]
44 fn fory_read_data(context: &mut ReadContext) -> Result<Self, Error> {
45 // xlang mode: read encoding header and decode accordingly
46 let bitor = context.reader.read_var_u36_small()?;
47 let len = bitor >> 2;
48 let encoding = bitor & 0b11;
49 let s = match encoding {
50 0 => context.reader.read_latin1_string(len as usize),
51 1 => context.reader.read_utf16_string(len as usize),
52 2 => {
53 let len = len as usize;
54 if context.is_check_string_read() {
55 context.reader.read_utf8_string(len)
56 } else {
57 context.reader.read_utf8_string_unchecked(len)
58 }
59 }
60 _ => {
61 return Err(Error::encoding_error(format!(
62 "wrong encoding value: {}",
63 encoding
64 )))
65 }
66 }?;
67 Ok(s)
68 }
69 #[inline]
70 fn fory_read_data_as_send_sync_any(
71 context: &mut ReadContext,

Callers

nothing calls this directly

Calls 6

read_var_u36_smallMethod · 0.80
read_latin1_stringMethod · 0.80
read_utf16_stringMethod · 0.80
read_utf8_stringMethod · 0.80
is_check_string_readMethod · 0.45

Tested by

no test coverage detected