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
//! Object builders for ergonomic construction of Git objects.
//!
//! # Why this module exists
//!
//! The data types in [`libvctrl_handler`] are immutable and enforce their own
//! invariants through constructors such as
//! [`Commit::new`](libvctrl_handler::Commit::new). While those constructors
//! are safe and correct, they often require every field to be supplied at once.
//! In real applications, fields may arrive gradually from parsing, user input,
//! or configuration. The builder pattern separates gradual assembly from final
//! validation.
//!
//! Each builder in this module consumes `self` on every setter, returns `Self`,
//! and exposes a single `build` method that performs validation and constructs
//! the final object. This design prevents partially configured builders from
//! being used accidentally after construction, while still allowing fluent
//! chains.
//!
//! # Module organization
//!
//! The module mirrors the object type hierarchy:
//!
//! - [`blob`] contains [`BlobBuilder`] for [`Blob`](libvctrl_handler::Blob).
//! - [`tree`] contains [`TreeBuilder`] and [`TreeEntryBuilder`] for
//! [`Tree`](libvctrl_handler::Tree) and
//! [`TreeEntry`](libvctrl_handler::TreeEntry).
//! - [`commit`] contains [`CommitBuilder`] for
//! [`Commit`](libvctrl_handler::Commit).
//! - [`tag`] contains [`TagBuilder`] for [`Tag`](libvctrl_handler::Tag).
//!
//! All builders are re-exported at this module level so callers can use
//! `libvctrl_core::object::CommitBuilder` instead of the longer submodule path.
//!
//! # Examples
//!
//! Construct a commit using the builder:
//!
//! ```
//! use libvctrl_core::object::CommitBuilder;
//! use libvctrl_handler::{Hash, UserID};
//!
//! let tree = Hash::from_bytes(&[0u8; 64]).unwrap();
//! let author = UserID::new("Alice".to_owned(), "alice@example.com".to_owned()).unwrap();
//! let committer = author.clone();
//!
//! let commit = CommitBuilder::new()
//! .tree(tree)
//! .author(author)
//! .committer(committer)
//! .message("Initial commit")
//! .build()
//! .unwrap();
//!
//! assert_eq!(commit.message(), "Initial commit");
//! ```
/// Blob builder.
///
/// This submodule contains [`BlobBuilder`], a builder for constructing
/// [`Blob`](libvctrl_handler::Blob) objects from arbitrary byte data.
/// Commit builder.
///
/// This submodule contains [`CommitBuilder`], a builder for constructing
/// [`Commit`](libvctrl_handler::Commit) objects with tree, parents, author,
/// committer, message, and optional metadata.
/// Tag builder.
///
/// This submodule contains [`TagBuilder`], a builder for constructing
/// [`Tag`](libvctrl_handler::Tag) objects with a name, target hash, optional
/// tagger, message, and optional metadata.
/// Tree builder.
///
/// This submodule contains [`TreeBuilder`] and [`TreeEntryBuilder`], builders
/// for constructing [`Tree`](libvctrl_handler::Tree) and
/// [`TreeEntry`](libvctrl_handler::TreeEntry) objects with sorted entries and
/// entry kinds.
/// Re-export of [`BlobBuilder`] for convenient access at the module root.
pub use BlobBuilder;
/// Re-export of [`CommitBuilder`] for convenient access at the module root.
pub use CommitBuilder;
/// Re-export of [`TagBuilder`] for convenient access at the module root.
pub use TagBuilder;
/// Re-export of [`TreeBuilder`] and [`TreeEntryBuilder`] for convenient access
/// at the module root.
pub use ;