1use core::fmt;
2
3#[derive(PartialEq, Debug, Clone, Copy)]
4pub enum Error {
5 TooFewShards,
6 TooManyShards,
7 TooFewDataShards,
8 TooManyDataShards,
9 TooFewParityShards,
10 TooManyParityShards,
11 TooFewBufferShards,
12 TooManyBufferShards,
13 IncorrectShardSize,
14 TooFewShardsPresent,
15 EmptyShard,
16 InvalidIndex,
17 InvalidParityMatrix,
18 SingularMatrix,
19}
20
21impl fmt::Display for Error {
22 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23 match self {
24 Error::TooFewShards => write!(f, "Too few shards"),
25 Error::TooManyShards => write!(f, "Too many shards"),
26 Error::TooFewDataShards => write!(f, "Too few data shards"),
27 Error::TooManyDataShards => write!(f, "Too many data shards"),
28 Error::TooFewParityShards => write!(f, "Too few parity shards"),
29 Error::TooManyParityShards => write!(f, "Too many parity shards"),
30 Error::TooFewBufferShards => write!(f, "Too few buffer shards"),
31 Error::TooManyBufferShards => write!(f, "Too many buffer shards"),
32 Error::IncorrectShardSize => write!(f, "Incorrect shard size"),
33 Error::TooFewShardsPresent => write!(f, "Too few shards present for reconstruction"),
34 Error::EmptyShard => write!(f, "Empty shard"),
35 Error::InvalidIndex => write!(f, "Invalid index"),
36 Error::InvalidParityMatrix => write!(f, "Invalid parity matrix"),
37 Error::SingularMatrix => write!(f, "Singular matrix"),
38 }
39 }
40}
41
42impl std::error::Error for Error {}
43
44#[derive(PartialEq, Debug, Clone, Copy)]
45pub enum SBSError {
46 TooManyCalls,
47 LeftoverShards,
48 RSError(Error),
49}
50
51impl fmt::Display for SBSError {
52 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
53 match self {
54 SBSError::TooManyCalls => write!(f, "Too many calls"),
55 SBSError::LeftoverShards => write!(f, "Leftover shards"),
56 SBSError::RSError(e) => write!(f, "{e}"),
57 }
58 }
59}
60
61impl std::error::Error for SBSError {}