Method
write
(&mut self, out: &mut Vec<u8>, n: u64)
Source from the content-addressed store, hash-verified
| 58 | pub(super) struct Delta(pub u64); |
| 59 | impl Delta { |
| 60 | pub fn write(&mut self, out: &mut Vec<u8>, n: u64) { |
| 61 | let d = n.wrapping_sub(self.0); |
| 62 | put(out, (d << 1) ^ ((d as i64 >> 63) as u64)); |
| 63 | self.0 = n; |
| 64 | } |
| 65 | pub fn read(&mut self, input: &mut &[u8]) -> FormatResult<u64> { |
| 66 | let z = get(input)?; |
| 67 | self.0 = self.0.wrapping_add((z >> 1) ^ 0u64.wrapping_sub(z & 1)); |
Tested by
no test coverage detected