edgefirst_tensor/
error.rs1pub type Result<T, E = Error> = std::result::Result<T, E>;
5
6#[derive(Debug)]
7pub enum Error {
8 IoError(std::io::Error),
9 #[cfg(unix)]
10 NixError(nix::Error),
11 NotImplemented(String),
12 InvalidSize(usize),
13 ShapeMismatch(String),
14 #[cfg(target_os = "linux")]
15 UnknownDeviceType(u64, u64),
16 InvalidMemoryType(String),
17 PboDisconnected,
19 PboMapped,
21 #[cfg(feature = "ndarray")]
22 NdArrayError(ndarray::ShapeError),
23}
24
25impl From<std::io::Error> for Error {
26 fn from(err: std::io::Error) -> Self {
27 Error::IoError(err)
28 }
29}
30#[cfg(unix)]
31impl From<nix::Error> for Error {
32 fn from(err: nix::Error) -> Self {
33 Error::NixError(err)
34 }
35}
36
37#[cfg(feature = "ndarray")]
38impl From<ndarray::ShapeError> for Error {
39 fn from(err: ndarray::ShapeError) -> Self {
40 Error::NdArrayError(err)
41 }
42}
43
44impl std::fmt::Display for Error {
45 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46 write!(f, "{self:?}")
47 }
48}
49
50impl std::error::Error for Error {}