MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_bit

Method read_bit

nodedb-codec/src/double_delta.rs:89–101  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

87 }
88
89 pub(crate) fn read_bit(&mut self) -> Result<bool, CodecError> {
90 let byte_idx = self.bit_pos / 8;
91 if byte_idx >= self.buf.len() {
92 return Err(CodecError::Truncated {
93 expected: byte_idx + 1,
94 actual: self.buf.len(),
95 });
96 }
97 let bit_idx = 7 - (self.bit_pos % 8);
98 let bit = (self.buf[byte_idx] >> bit_idx) & 1 == 1;
99 self.bit_pos += 1;
100 Ok(bit)
101 }
102
103 pub(crate) fn read_bits(&mut self, num_bits: usize) -> Result<u64, CodecError> {
104 let mut value = 0u64;

Callers 4

read_bitsMethod · 0.80
decode_dodFunction · 0.80
decode_timestampMethod · 0.80
decode_valueMethod · 0.80

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected