1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 11:41:15 +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,10 @@
#[derive(Debug)]
pub enum Error {
InvalidPath(crate::store::StorePath),
BadStorePath(std::path::PathBuf),
BadNarInfo,
IOError(std::io::Error),
HttpError(reqwest::Error),
Misc(String),
Foreign(CppException),
}
@ -11,12 +15,24 @@ impl From<std::io::Error> for Error {
}
}
impl From<reqwest::Error> for Error {
fn from(err: reqwest::Error) -> Self {
Error::HttpError(err)
}
}
impl From<Error> for CppException {
fn from(err: Error) -> Self {
match err {
Error::InvalidPath(_) => unsafe { make_error("invalid path") }, // FIXME
Error::BadNarInfo => unsafe { make_error(".narinfo file is corrupt") }, // FIXME
Error::BadStorePath(path) => unsafe {
make_error(&format!("path '{}' is not a store path", path.display()))
}, // FIXME
Error::IOError(err) => unsafe { make_error(&err.to_string()) },
Error::HttpError(err) => unsafe { make_error(&err.to_string()) },
Error::Foreign(ex) => ex,
Error::Misc(s) => unsafe { make_error(&s) },
Error::IOError(err) => unsafe { make_error(&err.to_string()) },
}
}
}