Basic BinaryCacheStore implementation using async Rust
This commit is contained in:
+17
-1
@@ -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()) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user