1#![cfg_attr(
25 all(doc, feature = "document-features"),
26 doc = ::document_features::document_features!()
27)]
28#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))]
29#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
30
31#[cfg(all(not(feature = "sha1"), not(feature = "sha256")))]
32compile_error!("Please set either the `sha1` or the `sha256` feature flag");
33
34#[path = "oid.rs"]
35mod borrowed;
36pub use borrowed::{oid, Error};
37
38pub mod hasher;
40pub use hasher::_impl::{hasher, Hasher};
41
42pub mod io;
44pub use io::_impl::{bytes, bytes_of_file, bytes_with_hasher};
45
46mod object_id;
47pub use object_id::{decode, ObjectId};
48
49pub mod prefix;
51
52pub mod verify;
54
55#[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy, Debug)]
60#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
61pub struct Prefix {
62 bytes: ObjectId,
63 hex_len: usize,
64}
65
66#[cfg(feature = "sha1")]
68const SIZE_OF_SHA1_DIGEST: usize = 20;
69#[cfg(feature = "sha1")]
71const SIZE_OF_SHA1_HEX_DIGEST: usize = 2 * SIZE_OF_SHA1_DIGEST;
72
73#[cfg(feature = "sha256")]
75const SIZE_OF_SHA256_DIGEST: usize = 32;
76#[cfg(feature = "sha256")]
78const SIZE_OF_SHA256_HEX_DIGEST: usize = 2 * SIZE_OF_SHA256_DIGEST;
79
80#[cfg(feature = "sha1")]
81const EMPTY_BLOB_SHA1: &[u8; SIZE_OF_SHA1_DIGEST] =
82 b"\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91";
83#[cfg(feature = "sha1")]
84const EMPTY_TREE_SHA1: &[u8; SIZE_OF_SHA1_DIGEST] =
85 b"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04";
86
87#[cfg(feature = "sha256")]
88const EMPTY_BLOB_SHA256: &[u8; SIZE_OF_SHA256_DIGEST] = b"\x47\x3a\x0f\x4c\x3b\xe8\xa9\x36\x81\xa2\x67\xe3\xb1\xe9\xa7\xdc\xda\x11\x85\x43\x6f\xe1\x41\xf7\x74\x91\x20\xa3\x03\x72\x18\x13";
89#[cfg(feature = "sha256")]
90const EMPTY_TREE_SHA256: &[u8; SIZE_OF_SHA256_DIGEST] = b"\x6e\xf1\x9b\x41\x22\x5c\x53\x69\xf1\xc1\x04\xd4\x5d\x8d\x85\xef\xa9\xb0\x57\xb5\x3b\x14\xb4\xb9\xb9\x39\xdd\x74\xde\xcc\x53\x21";
91
92#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
94#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
95#[non_exhaustive]
96pub enum Kind {
97 #[cfg_attr(feature = "sha1", default)]
99 #[cfg(feature = "sha1")]
100 Sha1 = 1,
101 #[cfg_attr(all(not(feature = "sha1"), feature = "sha256"), default)]
103 #[cfg(feature = "sha256")]
104 Sha256 = 2,
105}
106
107mod kind;