Return a new object ID with the given algorithm and hash. `hash` must be exactly the proper length for `algo` and this function panics if it is not. The extra internal storage of `hash`, if any, is zero filled.
(algo: HashAlgorithm, hash: &[u8])
| 46 | /// `hash` must be exactly the proper length for `algo` and this function panics if it is not. |
| 47 | /// The extra internal storage of `hash`, if any, is zero filled. |
| 48 | pub fn new(algo: HashAlgorithm, hash: &[u8]) -> Self { |
| 49 | let mut data = [0u8; GIT_MAX_RAWSZ]; |
| 50 | // This verifies that the length of `hash` is correct. |
| 51 | data[0..algo.raw_len()].copy_from_slice(hash); |
| 52 | Self { |
| 53 | hash: data, |
| 54 | algo: algo as u32, |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /// Return the algorithm for this object ID. |
| 59 | /// |
nothing calls this directly
no test coverage detected