git_hash/
lib.rs

1//! This crate provides types for identifying git objects using a hash digest.
2//!
3//! These are provided in borrowed versions as well as owned ones.
4//! ## Feature Flags
5#![cfg_attr(
6    feature = "document-features",
7    cfg_attr(doc, doc = ::document_features::document_features!())
8)]
9#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
10#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
11
12#[path = "oid.rs"]
13mod borrowed;
14pub use borrowed::oid;
15
16mod object_id;
17pub use object_id::{decode, ObjectId};
18
19///
20pub mod prefix;
21
22/// An partial owned hash possibly identifying an object uniquely,
23/// whose non-prefix bytes are zeroed.
24#[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy, Debug)]
25#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
26pub struct Prefix {
27    bytes: ObjectId,
28    hex_len: usize,
29}
30
31/// The size of a SHA1 hash digest in bytes
32const SIZE_OF_SHA1_DIGEST: usize = 20;
33
34/// Denotes the kind of function to produce a `Id`
35#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
36#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
37pub enum Kind {
38    /// The Sha1 hash with 160 bits.
39    Sha1 = 1,
40}
41
42mod kind;