(&mut self)
| 1246 | } |
| 1247 | |
| 1248 | fn read_git_object_id(&mut self) -> Result<GitObjectId, OperationCodecError> { |
| 1249 | let (algorithm, width) = match self.read_u8()? { |
| 1250 | 0 => (GitHashAlgorithm::Sha1, 20), |
| 1251 | 1 => (GitHashAlgorithm::Sha256, 32), |
| 1252 | tag => { |
| 1253 | return Err(OperationCodecError::new(format!( |
| 1254 | "unsupported Git hash algorithm tag {tag}" |
| 1255 | ))) |
| 1256 | } |
| 1257 | }; |
| 1258 | let end = self |
| 1259 | .offset |
| 1260 | .checked_add(width) |
| 1261 | .ok_or_else(|| OperationCodecError::new("Git object ID length overflow"))?; |
| 1262 | let bytes = self.bytes.get(self.offset..end).ok_or_else(|| { |
| 1263 | OperationCodecError::new("canonical object is truncated while reading Git object ID") |
| 1264 | })?; |
| 1265 | self.offset = end; |
| 1266 | GitObjectId::new(algorithm, bytes.to_vec()) |
| 1267 | } |
| 1268 | |
| 1269 | fn read_git_index(&mut self) -> Result<GitIndexState, OperationCodecError> { |
| 1270 | let digest = self.read_hash()?; |
no test coverage detected