1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Core enum definitions for Git object types.
//!
//! # Architecture
//! This module replaces raw integer mode bits (e.g., `0o100644`) with strongly-typed
//! enumerations. By using [`EntryKind`], the compiler enforces exhaustive matching,
//! preventing invalid or unrecognized file modes from propagating through the system.
//!
//! # Design Rationale
//! Raw mode bits are error-prone; a typo like `0o100646` is a valid integer but an invalid Git
//! mode. Enum variants encode domain logic directly into the type system, making the API
//! self-documenting and eliminating entire classes of runtime errors associated with
//! bit manipulation.
use crateentry_mode;
/// The kind of an entry in a Git tree.
///
/// # Why this exists
/// Git stores filesystem objects (files, directories, symlinks) in tree objects.
/// Each entry is identified by a 32-bit mode. This enum abstracts those raw bits into
/// a strongly-typed domain model. It ensures that only valid Git object types can be
/// represented, preventing invalid states (e.g., a mode of `0o000000`) from being
/// constructed.
///
/// # How it works
/// The enum is marked as `#[non_exhaustive]` to allow for the addition of new Git
/// object types in the future without breaking downstream API compatibility. Consumers
/// must include a `_` catch-all arm when matching.
///
/// # Examples
///
/// ```
/// # use libvctrl_handler::enums::EntryKind;
/// let kind = EntryKind::Blob;
/// assert_eq!(kind.mode(), 0o100_644);
/// ```