1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 23:11:16 +02:00

Basic BinaryCacheStore implementation using async Rust

This commit is contained in:
Eelco Dolstra 2019-09-12 17:39:25 +02:00
parent 98ef11677c
commit dd5d76e2ed
8 changed files with 1877 additions and 11 deletions

View file

@ -1,6 +1,11 @@
#![feature(await_macro, async_await)]
mod binary_cache_store;
mod error;
mod foreign;
mod store;
mod tarfile;
mod path_info;
pub use error::Error;
@ -30,3 +35,36 @@ pub extern "C" fn unpack_tarfile(
) -> CBox<Result<(), error::CppException>> {
CBox::new(tarfile::unpack_tarfile(source, dest_dir).map_err(|err| err.into()))
}
#[no_mangle]
pub extern "C" fn rust_test() {
use crate::store::Store;
use futures::future::{FutureExt, TryFutureExt};
use std::path::Path;
let fut = async move {
let store: Box<dyn Store> = Box::new(binary_cache_store::BinaryCacheStore::new(
"https://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());
Ok(())
};
tokio::run(fut.boxed().compat());
}