1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Error types for shravan.
use alloc::string::String;
use serde::{Deserialize, Serialize};
use thiserror::Error;
/// Result type alias for shravan operations.
pub type Result<T> = core::result::Result<T, ShravanError>;
/// Errors produced by shravan codec operations.
#[derive(Debug, Error, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ShravanError {
/// The audio format is not supported.
#[error("unsupported format")]
UnsupportedFormat,
/// The file header is invalid or corrupt.
#[error("invalid header: {0}")]
InvalidHeader(String),
/// An error occurred during decoding.
#[error("decode error: {0}")]
DecodeError(String),
/// An error occurred during encoding.
#[error("encode error: {0}")]
EncodeError(String),
/// Unexpected end of input data.
#[error("unexpected end of stream")]
EndOfStream,
/// The sample rate is invalid or unsupported.
#[error("invalid sample rate: {0} Hz")]
InvalidSampleRate(u32),
/// The channel count is invalid or unsupported.
#[error("invalid channel count: {0}")]
InvalidChannels(u16),
}