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

Method read_exact

atomic-core/src/operation/codec.rs:882–897  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

880 }
881
882 fn read_exact<const N: usize>(&mut self) -> Result<[u8; N], OperationCodecError> {
883 let end = self
884 .offset
885 .checked_add(N)
886 .ok_or_else(|| OperationCodecError::new("canonical object offset overflow"))?;
887 let bytes = self.bytes.get(self.offset..end).ok_or_else(|| {
888 OperationCodecError::new(format!(
889 "canonical object is truncated at byte {} while reading {N} bytes",
890 self.offset
891 ))
892 })?;
893 self.offset = end;
894 bytes
895 .try_into()
896 .map_err(|_| OperationCodecError::new("invalid fixed-width canonical field"))
897 }
898
899 fn read_u8(&mut self) -> Result<u8, OperationCodecError> {
900 Ok(self.read_exact::<1>()?[0])

Callers 15

newMethod · 0.45
random_mac_keyFunction · 0.45
read_u32Method · 0.45
read_u64Method · 0.45
read_i64Method · 0.45
read_hashMethod · 0.45
read_set_idMethod · 0.45
read_operation_idMethod · 0.45
read_working_copyMethod · 0.45
deserializeMethod · 0.45
read_fromMethod · 0.45

Calls 1

getMethod · 0.65

Tested by 1

newMethod · 0.36