flexaudio_core/
addon_error.rs1use crate::ErrorKind;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6#[non_exhaustive]
7pub enum AddonErrorKind {
8 VadModelLoad,
10 VadInference,
12 VadInvalidConfig,
14 VadInvalidFormat,
16 VadResample,
18 VadReset,
20 FlacIo,
22 FlacUnsupported,
24 FlacEncoder,
26}
27impl AddonErrorKind {
28 pub fn error_kind(self) -> ErrorKind {
30 match self {
31 Self::VadModelLoad => ErrorKind::Backend,
32 Self::VadInference => ErrorKind::Backend,
33 Self::VadInvalidConfig => ErrorKind::InvalidArg,
34 Self::VadInvalidFormat => ErrorKind::InvalidArg,
35 Self::VadResample => ErrorKind::Backend,
36 Self::VadReset => ErrorKind::Backend,
37 Self::FlacIo => ErrorKind::Backend,
38 Self::FlacUnsupported => ErrorKind::InvalidArg,
39 Self::FlacEncoder => ErrorKind::Backend,
40 }
41 }
42 pub fn as_str(self) -> &'static str {
44 match self {
45 Self::VadModelLoad => "vadModelLoad",
46 Self::VadInference => "vadInference",
47 Self::VadInvalidConfig => "vadInvalidConfig",
48 Self::VadInvalidFormat => "vadInvalidFormat",
49 Self::VadResample => "vadResample",
50 Self::VadReset => "vadReset",
51 Self::FlacIo => "flacIo",
52 Self::FlacUnsupported => "flacUnsupported",
53 Self::FlacEncoder => "flacEncoder",
54 }
55 }
56 pub fn explanation(self) -> &'static str {
58 match self {
59 Self::VadModelLoad => "VAD model loading failed; recreate the VAD session and retry.",
60 Self::VadInference => "VAD inference failed; reset the VAD session and retry.",
61 Self::VadInvalidConfig => {
62 "VAD configuration is invalid; correct the settings and retry."
63 }
64 Self::VadInvalidFormat => {
65 "VAD input format is invalid; use a sample rate within 8000..=192000 Hz and nonzero channels."
66 }
67 Self::VadResample => "VAD resampling failed; reset the VAD session and retry.",
68 Self::VadReset => "VAD reset failed; recreate the VAD session and retry.",
69 Self::FlacIo => {
70 "FLAC output I/O failed; check output access and available space, then retry."
71 }
72 Self::FlacUnsupported => {
73 "FLAC input is unsupported; correct the format and writer state, then retry."
74 }
75 Self::FlacEncoder => "FLAC encoding failed; recreate the writer and retry.",
76 }
77 }
78}