The Git index (staging area) lives in Index. Open a Repository, then call load_index (or write_index after changes). Index-related modules are grouped under worktree_index in rustdoc.
See also the Repository and Objects pages for opening repos and writing objects. Other library topics: Refs, Diff.
Reading the index
Index load reads index from disk; Repository load_index applies sparse-checkout and split-index rules the same way porcelain commands do. Entries are IndexEntry values with path, mode, object id, and stage.
Staging paths
porcelain::add::stage compares the index to the work tree once, hashes changed blobs, and writes the index back. Pass StageOptions for pathspecs and StageMode (All vs Update). Long-running staging reports through a ProgressSink; examples use NullProgress when no UI is needed.
The grit add command is a thin wrapper around this API.
Writing a tree from the index
write_tree_from_index builds a tree object from stage-0 entries (respecting the optional path prefix). It returns the root ObjectId. When the index cache-tree extension is valid, grit reuses cached subtree oids for speed; otherwise it walks entries and writes new tree objects through Odb.