1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#[cfg(all(feature = "gpu", not(target_os = "macos")))]
use crate::cl;
use std::{error, fmt};
#[derive(Debug, Clone)]
pub enum Error {
FullBuffer,
IndexOutOfBounds,
GPUError(String),
#[cfg(all(feature = "gpu", not(target_os = "macos")))]
ClError(cl::ClError),
DecodingError,
Other(String),
}
#[cfg(all(feature = "gpu", not(target_os = "macos")))]
impl From<cl::ClError> for Error {
fn from(e: cl::ClError) -> Self {
Self::ClError(e)
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
Error::FullBuffer => write!(
f,
"The size of the buffer cannot be greater than the hash arity."
),
Error::IndexOutOfBounds => write!(f, "The referenced index is outs of bounds."),
Error::GPUError(s) => write!(f, "GPU Error: {}", s),
#[cfg(all(feature = "gpu", not(target_os = "macos")))]
Error::ClError(e) => write!(f, "OpenCL Error: {}", e),
Error::DecodingError => write!(f, "PrimeFieldDecodingError"),
Error::Other(s) => write!(f, "{}", s),
}
}
}