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

Function get

atomic-core/examples/compact_semantic_codec/codec.rs:37–50  ·  view source on GitHub ↗
(input: &mut &[u8])

Source from the content-addressed store, hash-verified

35}
36
37fn get(input: &mut &[u8]) -> Result<u64> {
38 let mut n = 0;
39 for shift in (0..70).step_by(7) {
40 let (&b, rest) = input.split_first().context("truncated varint")?;
41 *input = rest;
42 ensure!(shift != 63 || b <= 1, "varint overflow");
43 n |= u64::from(b & 127) << shift;
44 if b < 128 {
45 ensure!(shift == 0 || b != 0, "noncanonical varint");
46 return Ok(n);
47 }
48 }
49 bail!("varint overflow")
50}
51
52// Wrapping differences cover the entire u64 domain, including descending IDs.
53fn delta(out: &mut Vec<u8>, previous: &mut u64, next: u64) {

Callers 6

undeltaFunction · 0.70
flagMethod · 0.70
countMethod · 0.70
bytesMethod · 0.70
leavesMethod · 0.70
decodeFunction · 0.70

Calls 1

contextMethod · 0.45

Tested by

no test coverage detected