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

Method read_var_u32

rust/fory-core/src/buffer.rs:743–775  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

741
742 #[inline(always)]
743 pub fn read_var_u32(&mut self) -> Result<u32, Error> {
744 let b0 = self.value_at(self.cursor)? as u32;
745 if b0 < 0x80 {
746 self.move_next(1);
747 return Ok(b0);
748 }
749
750 let b1 = self.value_at(self.cursor + 1)? as u32;
751 let mut encoded = (b0 & 0x7F) | ((b1 & 0x7F) << 7);
752 if b1 < 0x80 {
753 self.move_next(2);
754 return Ok(encoded);
755 }
756
757 let b2 = self.value_at(self.cursor + 2)? as u32;
758 encoded |= (b2 & 0x7F) << 14;
759 if b2 < 0x80 {
760 self.move_next(3);
761 return Ok(encoded);
762 }
763
764 let b3 = self.value_at(self.cursor + 3)? as u32;
765 encoded |= (b3 & 0x7F) << 21;
766 if b3 < 0x80 {
767 self.move_next(4);
768 return Ok(encoded);
769 }
770
771 let b4 = self.value_at(self.cursor + 4)? as u32;
772 encoded |= b4 << 28;
773 self.move_next(5);
774 Ok(encoded)
775 }
776
777 // ============ UINT64 (TypeId = 13) ============
778

Callers 15

read_var_i32Method · 0.80
read_usizeMethod · 0.80
read_any_type_infoMethod · 0.80
read_type_info_fastFunction · 0.80
read_collection_dataFunction · 0.80
read_vec_dataFunction · 0.80
fory_read_dataFunction · 0.80
read_type_infoFunction · 0.80
read_primitive_arrayFunction · 0.80
read_complex_arrayFunction · 0.80

Calls 2

move_nextMethod · 0.80
value_atMethod · 0.45

Tested by 3

test_buffer_varFunction · 0.64
test_var_i32Function · 0.64
fory_read_dataMethod · 0.64