Basic BinaryCacheStore implementation using async Rust

This commit is contained in:
Eelco Dolstra
2019-12-10 13:37:23 +01:00
parent 98ef11677c
commit dd5d76e2ed
8 changed files with 1877 additions and 11 deletions
+17 -1
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()) },
}
}
}