feat(tvix/castore): impl From<std::io::Error> for Error

Make it less annoying to convert from io::Error to this. We already have
one direction, doesn't hurt to have the other too.

Change-Id: I9fe2c6da608c9d54910ee8c397572aadb1d90d99
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10068
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-11-18 18:30:55 +02:00 committed by flokli
parent ebfe456251
commit 68e473ed6b

View file

@ -40,6 +40,16 @@ impl From<crate::tonic::Error> for Error {
}
}
impl From<std::io::Error> for Error {
fn from(value: std::io::Error) -> Self {
if value.kind() == std::io::ErrorKind::InvalidInput {
Error::InvalidRequest(value.to_string())
} else {
Error::StorageError(value.to_string())
}
}
}
// TODO: this should probably go somewhere else?
impl From<Error> for std::io::Error {
fn from(value: Error) -> Self {