blob: 42ecb9866c9f090fb7fbc9b490df8df7d4c1af7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
use super::{
error,
foreign::{self, CBox},
util,
};
#[no_mangle]
pub extern "C" fn unpack_tarfile(
source: foreign::Source,
dest_dir: &str,
) -> CBox<Result<(), error::CppException>> {
CBox::new(util::tarfile::unpack_tarfile(source, dest_dir).map_err(|err| err.into()))
}
#[no_mangle]
pub extern "C" fn rust_test() {
use crate::store::{self, Store};
use std::path::Path;
use tokio::runtime::Runtime;
let fut = async move {
let store: Box<dyn Store> = Box::new(store::BinaryCacheStore::new(
"http://cache.nixos.org".to_string(),
));
let path = store
.parse_store_path(&Path::new(
"/nix/store/7h7qgvs4kgzsn8a6rb273saxyqh4jxlz-konsole-18.12.3",
))
.unwrap();
/*
let info = store.query_path_info(&path).await.unwrap();
eprintln!("INFO = {:?}", info);
*/
let closure = store
.compute_path_closure(vec![path].into_iter().collect())
.await
.unwrap();
eprintln!("CLOSURE = {:?}", closure.len());
};
let rt = Runtime::new().unwrap();
rt.block_on(fut);
/*
let file = std::fs::File::open("test.nar").unwrap();
crate::nar::parse(&mut std::io::BufReader::new(file)).unwrap();
*/
}
|