3 unstable releases
0.2.0 | Mar 18, 2021 |
---|---|
0.1.1 | Mar 17, 2021 |
0.1.0 | Mar 17, 2021 |
#4 in #focuses
26 downloads per month
34KB
695 lines
anni-fetch
A library focuses on what git fetch does.
Example
use anni_fetch::client::Message::PackData;
use anni_fetch::{Pack, Client};
use std::io::Cursor;
use anni_fetch::client::RequestBuilder;
fn main() {
// create client
let client = Client::new("https://github.com/project-anni/repo.git");
// request and get message iterator
let iter = client.request(
RequestBuilder::new(true)
.command("fetch")
.argument("thin-pack")
.argument("ofs-delta")
.argument("deepen 1")
.want(&client.ls_ref("HEAD").expect("failed to get sha1 of HEAD"))
.argument("done")
.build()
).unwrap();
// prepare buffer for pack
let mut pack = Vec::new();
for msg in iter {
match msg {
// receive and insert into pack
PackData(mut d) => pack.append(&mut d),
_ => {}
}
}
let mut cursor = Cursor::new(pack);
// read pack
Pack::from_reader(&mut cursor).expect("invalid pack file");
}
Dependencies
~2.5–3.5MB
~92K SLoC