Skip to main content

git_zero_core/
lib.rs

1//! Allocation-free Git objects, repositories and wire primitives.
2//!
3//! `read` enables inflation, pack decoding and repository validation.
4//! `write` enables snapshots, pack/zlib encoding and pack caching.
5//!
6//! Storage and I/O belong to the caller. There is no `std`, `alloc`, allocator,
7//! global state, filesystem, or socket dependency in this crate.
8#![no_std]
9#![forbid(unsafe_code)]
10
11#[cfg(feature = "write")]
12pub mod cache;
13#[cfg(feature = "read")]
14pub mod checkout;
15pub mod http;
16pub mod io;
17#[cfg(any(feature = "read", feature = "write"))]
18mod names;
19pub mod object;
20#[cfg(any(feature = "read", feature = "write"))]
21pub mod pack;
22pub mod pktline;
23pub mod reader;
24pub mod repository;
25#[cfg(feature = "write")]
26pub mod snapshot;
27#[cfg(feature = "read")]
28pub mod validation;
29#[cfg(any(feature = "read", feature = "write"))]
30pub mod zlib;
31
32pub use object::{HexId, Object, ObjectDigest, ObjectFormat, ObjectId, ObjectInfo, ObjectKind};
33pub use reader::{ObjectHasher, ObjectReader};
34pub use repository::{
35    EmptyRepository, Head, IndexedRepository, ObjectMetadata, RefRepository, Reference, Repository,
36};
37#[cfg(feature = "write")]
38pub use snapshot::{
39    CommitIdentity, CommitOptions, Entry, EntryKind, File, Snapshot, SnapshotBuilder,
40};
41#[cfg(feature = "read")]
42pub use validation::{
43    RevisionLimits, RevisionOptions, RevisionState, SelectionOptions, ShallowChange,
44    ValidatedRepository, ValidationMetadata,
45};
46
47#[derive(Clone, Copy, Debug, Eq, PartialEq)]
48pub enum Error {
49    BufferTooSmall,
50    InvalidObjectId,
51    InvalidObject,
52    InvalidPacket,
53    InvalidRequest,
54    InvalidFileName,
55    UnsortedFiles,
56    InvalidReference,
57    ObjectNotFound,
58    Unsupported,
59    Backend,
60    CorruptPack,
61    InvalidZlib,
62    LimitExceeded,
63}
64
65pub type Result<T> = core::result::Result<T, Error>;
66
67mod fetch;
68pub use fetch::{BlobFilter, FetchOptions, HistoryPolicy};