gix_hash/verify.rs
1use crate::oid;
2use gix_error::Result;
3
4impl oid {
5 /// Verify that `self` matches the `expected` object ID.
6 ///
7 /// Returns an error classified as [`gix_error::Class::Corruption`] containing both object IDs if they differ.
8 #[inline]
9 pub fn verify(&self, expected: &oid) -> Result {
10 if self == expected {
11 Ok(())
12 } else {
13 Err(gix_error::message!("Hash was {self}, but should have been {expected}").corrupted_error())
14 }
15 }
16}