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

Function get

atomic-core/examples/semantic_codec_lab/control.rs:19–32  ·  view source on GitHub ↗
(input: &mut &[u8])

Source from the content-addressed store, hash-verified

17pub(super) const LENGTH: usize = 11;
18
19pub(super) fn get(input: &mut &[u8]) -> Result<u64> {
20 let mut n = 0;
21 for shift in (0..70).step_by(7) {
22 let (&b, rest) = input.split_first().context("truncated control varint")?;
23 *input = rest;
24 ensure!(shift != 63 || b <= 1, "control varint overflow");
25 n |= u64::from(b & 127) << shift;
26 if b < 128 {
27 ensure!(shift == 0 || b != 0, "noncanonical control varint");
28 return Ok(n);
29 }
30 }
31 anyhow::bail!("control varint overflow")
32}
33pub(super) trait Values {
34 fn value(&mut self, role: usize) -> Result<u64>;
35}

Callers 7

offsetFunction · 0.70
splitFunction · 0.70
valueMethod · 0.70
valueMethod · 0.70
undeltaFunction · 0.70
predict_kindsFunction · 0.70
restore_kindsFunction · 0.70

Calls 1

contextMethod · 0.45

Tested by

no test coverage detected