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

Function skip_string

rust/fory-core/src/serializer/skip.rs:66–88  ·  view source on GitHub ↗
(context: &mut ReadContext)

Source from the content-addressed store, hash-verified

64#[cold]
65#[inline(never)]
66fn skip_string(context: &mut ReadContext) -> Result<(), Error> {
67 let header = context.reader.read_var_u36_small()?;
68 let len = (header >> 2) as usize;
69 let encoding = header & 0b11;
70 match encoding {
71 // Latin1 and UTF-16 have no validation beyond readable bytes in the current reader.
72 0 | 1 => skip_bytes(context, len),
73 2 => {
74 if context.is_check_string_read() {
75 let start = context.reader.get_cursor();
76 context.reader.check_bound(len)?;
77 let bytes = context.reader.sub_slice(start, start + len)?;
78 std::str::from_utf8(bytes)
79 .map_err(|_| Error::encoding_error("invalid UTF-8 string"))?;
80 }
81 skip_bytes(context, len)
82 }
83 _ => Err(Error::encoding_error(format!(
84 "wrong encoding value: {}",
85 encoding
86 ))),
87 }
88}
89
90#[cold]
91#[inline(never)]

Callers 1

skip_valueFunction · 0.70

Calls 6

skip_bytesFunction · 0.85
read_var_u36_smallMethod · 0.80
get_cursorMethod · 0.80
check_boundMethod · 0.80
sub_sliceMethod · 0.80
is_check_string_readMethod · 0.45

Tested by

no test coverage detected