ndstruct/
error.rs

1use crate::{
2  coo::CooError,
3  csl::{CslError, CslLineConstructorError},
4  dense::DenseError,
5};
6use core::fmt::{Debug, Display, Formatter};
7
8/// Contains all errors related to ndstruct
9#[derive(Debug, Eq, PartialEq)]
10#[non_exhaustive]
11pub enum Error {
12  /// See [`cl_aux::Error`].
13  ClAux(cl_aux::Error),
14  /// See [`CooError`]
15  Coo(CooError),
16  /// See [`CslError`]
17  Csl(CslError),
18  /// [`CslLineConstructorError`]
19  CslLineConstructor(CslLineConstructorError),
20  /// See [`DenseError`]
21  Dense(DenseError),
22  /// The internal buffer can't store all necessary data
23  InsufficientCapacity,
24  /// An Unknown that probably shouldn't have happened
25  UnknownError,
26}
27
28impl Display for Error {
29  #[inline]
30  fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
31    Debug::fmt(self, f)
32  }
33}
34
35impl core::error::Error for Error {}
36
37impl From<cl_aux::Error> for Error {
38  #[inline]
39  fn from(from: cl_aux::Error) -> Self {
40    Self::ClAux(from)
41  }
42}
43
44impl From<CooError> for Error {
45  #[inline]
46  fn from(from: CooError) -> Self {
47    Self::Coo(from)
48  }
49}
50
51impl From<CslError> for Error {
52  #[inline]
53  fn from(from: CslError) -> Self {
54    Self::Csl(from)
55  }
56}
57
58impl From<CslLineConstructorError> for Error {
59  #[inline]
60  fn from(from: CslLineConstructorError) -> Self {
61    Self::CslLineConstructor(from)
62  }
63}
64
65impl From<DenseError> for Error {
66  #[inline]
67  fn from(from: DenseError) -> Self {
68    Self::Dense(from)
69  }
70}