zub/lib.rs
1//! zub - git-like object tree
2//!
3//! a content-addressed filesystem store for rootfs fragments with git-like semantics.
4//! similar in spirit to ostree but simpler, designed for composing Linux system images.
5//!
6//! # Core concepts
7//!
8//! - **Blob**: content-addressed file data (compressed with zstd)
9//! - **Tree**: a serialized directory structure (CBOR + zstd)
10//! - **Commit**: a snapshot of a tree with metadata (CBOR + zstd)
11//! - **Ref**: a named pointer to a commit (hierarchical, like git branches)
12//!
13//! # Hash format
14//!
15//! blob hash = SHA256(uid | gid | mode | xattr_count | xattrs... | content)
16//!
17//! where xattrs are sorted by name and each is: name_len | name | value_len | value
18//!
19//! # Example usage
20//!
21//! ```no_run
22//! use zub::{Repo, ops};
23//! use std::path::Path;
24//!
25//! // initialize a repository
26//! let repo = Repo::init(Path::new("/path/to/repo")).unwrap();
27//!
28//! // commit a directory
29//! let hash = ops::commit(&repo, Path::new("/source"), "my/ref", Some("initial commit"), None).unwrap();
30//!
31//! // checkout to a directory
32//! ops::checkout(&repo, "my/ref", Path::new("/destination"), ops::CheckoutOptions::default()).unwrap();
33//! ```
34
35mod config;
36mod error;
37mod hash;
38mod namespace;
39mod object;
40mod refs;
41mod repo;
42
43pub mod fs;
44pub mod ops;
45pub mod transport;
46pub mod types;
47
48pub use config::Config;
49pub use error::{Error, Result};
50pub use hash::{compute_blob_hash, Hash};
51pub use namespace::{
52 current_gid_map, current_uid_map, inside_to_outside, mappings_equal, outside_to_inside,
53 parse_id_map, remap, MapEntry, NsConfig,
54};
55pub use object::{
56 blob_exists, commit_path, read_blob, read_commit, read_tree, tree_path, write_blob,
57 write_commit, write_tree,
58};
59pub use ops::{du, stats, truncate_history, RefSize, RepoStats, TruncateStats};
60pub use refs::{
61 delete_ref, delete_refs_matching, list_refs, list_refs_matching, read_ref, ref_exists,
62 resolve_ref, write_ref,
63};
64pub use repo::Repo;
65pub use types::{ChangeKind, Commit, DiffEntry, EntryKind, SparseRegion, Tree, TreeEntry, Xattr};