mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
Update to async/await-enabled tokio
This commit is contained in:
parent
7f08975050
commit
a6f0bef0a7
7 changed files with 274 additions and 533 deletions
758
nix-rust/Cargo.lock
generated
758
nix-rust/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -11,11 +11,11 @@ crate-type = ["cdylib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tar = "0.4"
|
tar = "0.4"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
futures-preview = { version = "=0.3.0-alpha.18", features = ["compat"] }
|
futures-preview = { version = "=0.3.0-alpha.19", features = ["compat"] }
|
||||||
#hyper = "0.12"
|
#hyper = "0.12"
|
||||||
reqwest = { version = "0.9", default-features = false, features = ["rustls-tls"] }
|
reqwest = { version = "=0.10.0-alpha.2", default-features = false }
|
||||||
http = "0.1"
|
http = "0.1"
|
||||||
tokio = { version = "0.1", default-features = false }
|
tokio = { version = "0.2.0-alpha.6", default-features = false, features = ["rt-full"] }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
byteorder = "1.3"
|
byteorder = "1.3"
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ endif
|
||||||
$(libnixrust_PATH): $(call rwildcard, $(d)/src, *.rs) $(d)/Cargo.toml
|
$(libnixrust_PATH): $(call rwildcard, $(d)/src, *.rs) $(d)/Cargo.toml
|
||||||
$(trace-gen) cd nix-rust && CARGO_HOME=$$(if [[ -d vendor ]]; then echo vendor; fi) \
|
$(trace-gen) cd nix-rust && CARGO_HOME=$$(if [[ -d vendor ]]; then echo vendor; fi) \
|
||||||
$(libnixrust_BUILD_FLAGS) \
|
$(libnixrust_BUILD_FLAGS) \
|
||||||
RUSTC_BOOTSTRAP=1 cargo build $(RUST_MODE) $$(if [[ -d vendor ]]; then echo --offline; fi) \
|
cargo build $(RUST_MODE) $$(if [[ -d vendor ]]; then echo --offline; fi) \
|
||||||
&& touch target/$(RUST_DIR)/libnixrust.$(SO_EXT)
|
&& touch target/$(RUST_DIR)/libnixrust.$(SO_EXT)
|
||||||
|
|
||||||
$(libnixrust_INSTALL_PATH): $(libnixrust_PATH)
|
$(libnixrust_INSTALL_PATH): $(libnixrust_PATH)
|
||||||
|
|
|
@ -14,10 +14,9 @@ pub extern "C" fn unpack_tarfile(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn rust_test() {
|
pub extern "C" fn rust_test() {
|
||||||
/*
|
|
||||||
use crate::store::{self, Store};
|
use crate::store::{self, Store};
|
||||||
use futures::future::{FutureExt, TryFutureExt};
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
let fut = async move {
|
let fut = async move {
|
||||||
let store: Box<dyn Store> = Box::new(store::BinaryCacheStore::new(
|
let store: Box<dyn Store> = Box::new(store::BinaryCacheStore::new(
|
||||||
|
@ -36,17 +35,21 @@ pub extern "C" fn rust_test() {
|
||||||
eprintln!("INFO = {:?}", info);
|
eprintln!("INFO = {:?}", info);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let closure = store.compute_path_closure(vec![path].into_iter().collect()).await.unwrap();
|
let closure = store
|
||||||
|
.compute_path_closure(vec![path].into_iter().collect())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
eprintln!("CLOSURE = {:?}", closure.len());
|
eprintln!("CLOSURE = {:?}", closure.len());
|
||||||
|
|
||||||
Ok(())
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tokio::run(fut.boxed().compat());
|
let rt = Runtime::new().unwrap();
|
||||||
*/
|
|
||||||
|
|
||||||
|
rt.block_on(fut);
|
||||||
|
|
||||||
|
/*
|
||||||
let file = std::fs::File::open("test.nar").unwrap();
|
let file = std::fs::File::open("test.nar").unwrap();
|
||||||
|
|
||||||
crate::nar::parse(&mut std::io::BufReader::new(file)).unwrap();
|
crate::nar::parse(&mut std::io::BufReader::new(file)).unwrap();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![feature(await_macro, async_await)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use super::{Store, StorePath, PathInfo};
|
use super::{PathInfo, Store, StorePath};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use futures::compat::Future01CompatExt;
|
|
||||||
|
|
||||||
pub struct BinaryCacheStore {
|
pub struct BinaryCacheStore {
|
||||||
base_uri: String,
|
base_uri: String,
|
||||||
|
@ -27,22 +26,17 @@ impl Store for BinaryCacheStore {
|
||||||
let store_dir = self.store_dir().to_string();
|
let store_dir = self.store_dir().to_string();
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let response = client
|
let response = client.get(&uri).send().await?;
|
||||||
.get(&uri)
|
|
||||||
.send()
|
|
||||||
.compat()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if response.status() == reqwest::StatusCode::NOT_FOUND || response.status() == reqwest::StatusCode::FORBIDDEN {
|
if response.status() == reqwest::StatusCode::NOT_FOUND
|
||||||
|
|| response.status() == reqwest::StatusCode::FORBIDDEN
|
||||||
|
{
|
||||||
return Err(Error::InvalidPath(path));
|
return Err(Error::InvalidPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut response = response.error_for_status()?;
|
let response = response.error_for_status()?;
|
||||||
|
|
||||||
let body = response
|
let body = response.text().await?;
|
||||||
.text()
|
|
||||||
.compat()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
PathInfo::parse_nar_info(&body, &store_dir)
|
PathInfo::parse_nar_info(&body, &store_dir)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ useClang ? false }:
|
{ useClang ? false }:
|
||||||
|
|
||||||
with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.09.tar.gz) {};
|
with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/bb1013511e1e5edcf314df8321acf2f3c536df0d.tar.gz) {};
|
||||||
|
|
||||||
with import ./release-common.nix { inherit pkgs; };
|
with import ./release-common.nix { inherit pkgs; };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue