1mod bind;
2pub mod erasure;
3pub mod galois;
4
5pub use bind::ec;
6pub use bind::gf;
7
8#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 #[error("Too Many Erased Blocks: {0} erased, up to {1} allowed")]
14 TooManyErasures(usize, usize),
15 #[error("Invalid Arguments: {0}")]
17 InvalidArguments(String),
18 #[error("Internal Error: {0}")]
20 InternalError(String),
21 #[error("Error: {0}")]
23 Other(String),
24}
25
26#[allow(dead_code)]
27impl Error {
28 fn too_many_erasures(erasures: usize, max_erasures: usize) -> Self {
29 Self::TooManyErasures(erasures, max_erasures)
30 }
31
32 fn invalid_arguments(msg: impl Into<String>) -> Self {
33 Self::InvalidArguments(msg.into())
34 }
35
36 fn internal_error(msg: impl Into<String>) -> Self {
37 Self::InternalError(msg.into())
38 }
39
40 fn other(msg: impl Into<String>) -> Self {
41 Self::Other(msg.into())
42 }
43}