gix-hash 0.28.0

Borrowed and owned git hash digests used to identify git objects
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::oid;
use gix_error::Result;

impl oid {
    /// Verify that `self` matches the `expected` object ID.
    ///
    /// Returns an error classified as [`gix_error::Class::Corruption`] containing both object IDs if they differ.
    #[inline]
    pub fn verify(&self, expected: &oid) -> Result {
        if self == expected {
            Ok(())
        } else {
            Err(gix_error::message!("Hash was {self}, but should have been {expected}").corrupted_error())
        }
    }
}