1#![cfg_attr(
6 all(doc, feature = "document-features"),
7 doc = ::document_features::document_features!()
8)]
9#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))]
10#![deny(missing_docs, rust_2018_idioms, unsafe_code)]
11
12#[cfg(all(not(feature = "sha1"), not(feature = "sha256")))]
13compile_error!("Please set either the `sha1` or the `sha256` feature flag");
14
15#[path = "oid.rs"]
16mod borrowed;
17pub use borrowed::{oid, Error};
18
19pub mod hasher;
21pub use hasher::_impl::{hasher, Hasher};
22
23pub mod io;
25pub use io::_impl::{bytes, bytes_of_file, bytes_with_hasher};
26
27mod object_id;
28pub use object_id::{decode, ObjectId};
29
30pub mod prefix;
32
33pub mod verify;
35
36#[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy, Debug)]
41#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
42pub struct Prefix {
43 bytes: ObjectId,
44 hex_len: usize,
45}
46
47#[cfg(feature = "sha1")]
49const SIZE_OF_SHA1_DIGEST: usize = 20;
50#[cfg(feature = "sha1")]
52const SIZE_OF_SHA1_HEX_DIGEST: usize = 2 * SIZE_OF_SHA1_DIGEST;
53
54#[cfg(feature = "sha256")]
56const SIZE_OF_SHA256_DIGEST: usize = 32;
57#[cfg(feature = "sha256")]
59const SIZE_OF_SHA256_HEX_DIGEST: usize = 2 * SIZE_OF_SHA256_DIGEST;
60
61#[cfg(feature = "sha1")]
62const EMPTY_BLOB_SHA1: &[u8; SIZE_OF_SHA1_DIGEST] =
63 b"\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91";
64#[cfg(feature = "sha1")]
65const EMPTY_TREE_SHA1: &[u8; SIZE_OF_SHA1_DIGEST] =
66 b"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04";
67
68#[cfg(feature = "sha256")]
69const 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";
70#[cfg(feature = "sha256")]
71const 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";
72
73#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
75#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
76#[non_exhaustive]
77pub enum Kind {
78 #[cfg_attr(feature = "sha1", default)]
80 #[cfg(feature = "sha1")]
81 Sha1 = 1,
82 #[cfg_attr(all(not(feature = "sha1"), feature = "sha256"), default)]
84 #[cfg(feature = "sha256")]
85 Sha256 = 2,
86}
87
88mod kind;