MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get

Function get

atomic-core/src/change/format_v3/graph_fields/wire.rs:37–56  ·  view source on GitHub ↗
(input: &mut &[u8])

Source from the content-addressed store, hash-verified

35 out.push(n as u8);
36}
37pub(super) fn get(input: &mut &[u8]) -> FormatResult<u64> {
38 let mut n = 0;
39 for shift in (0..70).step_by(7) {
40 let (&b, rest) = input
41 .split_first()
42 .ok_or_else(|| invalid("truncated varint"))?;
43 *input = rest;
44 if shift == 63 && b > 1 {
45 return Err(invalid("varint overflow"));
46 }
47 n |= u64::from(b & 127) << shift;
48 if b < 128 {
49 if shift > 0 && b == 0 {
50 return Err(invalid("noncanonical varint"));
51 }
52 return Ok(n);
53 }
54 }
55 Err(invalid("varint overflow"))
56}
57#[derive(Default)]
58pub(super) struct Delta(pub u64);
59impl Delta {

Callers 5

readMethod · 0.70
parseMethod · 0.70
flagMethod · 0.70
countMethod · 0.70
opMethod · 0.70

Calls 1

invalidFunction · 0.70

Tested by

no test coverage detected