gix-hash 0.27.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::ExnMessageResult;

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) -> ExnMessageResult {
        if self == expected {
            Ok(())
        } else {
            Err(gix_error::corruption(format!("Hash was {self}, but should have been {expected}")).into())
        }
    }
}