anni_fetch/
lib.rs

1//! anni-fetch
2//!
3//! `anni-fetch` is interact with git server and fetch pack files from it.
4//! It implemented git v2 protocol and PACK file uncompression, which is used in git fetch procedure.
5//!
6//! # Example
7//!
8//! ```rust
9//! use anni_fetch::client::Message::PackData;
10//! use anni_fetch::{Pack, Client};
11//! use std::io::Cursor;
12//! use anni_fetch::client::RequestBuilder;
13//!
14//! fn main() {
15//!     let client = Client::new("https://github.com/project-anni/repo.git");
16//!     let iter = client.request(
17//!         RequestBuilder::new(true)
18//!             .command("fetch")
19//!             .argument("thin-pack")
20//!             .argument("ofs-delta")
21//!             .argument("deepen 1")
22//!             .want(&client.ls_ref("HEAD").expect("failed to get sha1 of HEAD"))
23//!             .argument("done")
24//!             .build()
25//!     ).unwrap();
26//!     let mut pack = Vec::new();
27//!     for msg in iter {
28//!         match msg {
29//!             PackData(mut d) => pack.append(&mut d),
30//!             _ => {}
31//!         }
32//!     }
33//!     let mut cursor = Cursor::new(pack);
34//!     Pack::from_reader(&mut cursor).expect("invalid pack file");
35//! }
36//! ```
37//!
38//! You can use `match` to filter the type of message you want.
39//! For example, you can just receive `Message::PackData` and
40//! write the content to a `pak` file.
41
42pub mod io;
43pub mod pack;
44pub mod client;
45
46pub use client::Client;
47pub use pack::Pack;