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

Function get

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

Source from the content-addressed store, hash-verified

77 out.push(n as u8);
78}
79fn get(input: &mut &[u8]) -> Result<u64> {
80 let mut n = 0;
81 for shift in (0..70).step_by(7) {
82 let (&b, rest) = input.split_first().context("truncated graph varint")?;
83 *input = rest;
84 ensure!(shift != 63 || b <= 1, "graph varint overflow");
85 n |= u64::from(b & 127) << shift;
86 if b < 128 {
87 ensure!(shift == 0 || b != 0, "noncanonical graph varint");
88 return Ok(n);
89 }
90 }
91 anyhow::bail!("graph varint overflow")
92}
93fn delta(out: &mut Vec<u8>, previous: &mut u64, next: u64) {
94 let d = next.wrapping_sub(*previous);
95 put(out, (d << 1) ^ ((d as i64 >> 63) as u64));

Callers 3

vectorFunction · 0.70
undeltaFunction · 0.70
numericFunction · 0.70

Calls 1

contextMethod · 0.45

Tested by

no test coverage detected