MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / encode_varint

Function encode_varint

crates/commitlog/src/varint.rs:24–34  ·  view source on GitHub ↗
(mut value: usize, out: &mut impl BufWriter)

Source from the content-addressed store, hash-verified

22
23#[inline]
24pub fn encode_varint(mut value: usize, out: &mut impl BufWriter) {
25 loop {
26 if value < 0x80 {
27 out.put_u8(value as u8);
28 break;
29 } else {
30 out.put_u8(((value & 0x7f) | 0x80) as u8);
31 value >>= 7;
32 }
33 }
34}
35
36#[inline]
37pub fn decode_varint<'a>(reader: &mut impl BufReader<'a>) -> Result<usize, DecodeError> {

Callers 1

encodeMethod · 0.85

Calls 1

put_u8Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…