1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum SilkError {
5 #[error("Invalid")]
6 Invalid,
7 #[error("EncInputInvalidNoOfSamples")]
8 EncInputInvalidNoOfSamples,
9 #[error("EncFsNotSupported")]
10 EncFsNotSupported,
11 #[error("EncPacketSizeNotSupported")]
12 EncPacketSizeNotSupported,
13 #[error("EncPayloadBufTooShort")]
14 EncPayloadBufTooShort,
15 #[error("EncInvalidLossRate")]
16 EncInvalidLossRate,
17 #[error("EncInvalidComplexitySetting")]
18 EncInvalidComplexitySetting,
19 #[error("EncInvalidInbandFecSetting")]
20 EncInvalidInbandFecSetting,
21 #[error("EncInvalidDtxSetting")]
22 EncInvalidDtxSetting,
23 #[error("EncInternalError")]
24 EncInternalError,
25 #[error("DecInvalidSamplingFrequency")]
26 DecInvalidSamplingFrequency,
27 #[error("DecPayloadTooLarge")]
28 DecPayloadTooLarge,
29 #[error("DecPayloadError")]
30 DecPayloadError,
31 #[error("OTHER {0}")]
32 Other(i32),
33}
34
35impl From<i32> for SilkError {
36 fn from(code: i32) -> Self {
37 match code {
38 -1 => Self::EncInputInvalidNoOfSamples,
39 -2 => Self::EncFsNotSupported,
40 -3 => Self::EncPacketSizeNotSupported,
41 -4 => Self::EncPayloadBufTooShort,
42 -5 => Self::EncInvalidLossRate,
43 -6 => Self::EncInvalidComplexitySetting,
44 -7 => Self::EncInvalidInbandFecSetting,
45 -8 => Self::EncInvalidDtxSetting,
46 -9 => Self::EncInternalError,
47 -10 => Self::DecInvalidSamplingFrequency,
48 -11 => Self::DecPayloadTooLarge,
49 -12 => Self::DecPayloadError,
50 _ => Self::Other(code),
51 }
52 }
53}