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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::SstvMode;
/// Result type used by Rasterwave APIs.
pub type Result<T> = std::result::Result<T, Error>;
/// Errors returned by codec construction and validation.
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
/// A sample rate cannot represent the required SSTV or radiofax tones.
#[error("sample rate {0} Hz is outside the supported range 8,000..=384,000 Hz")]
InvalidSampleRate(u32),
/// An image buffer length does not match its declared dimensions.
#[error("image buffer has {actual} pixels, expected {expected}")]
InvalidImageBuffer {
/// Expected number of pixels.
expected: usize,
/// Actual number of pixels.
actual: usize,
},
/// An interleaved RGB byte buffer does not contain exactly three bytes per
/// declared pixel.
#[error("RGB byte buffer has {actual} bytes, expected {expected}")]
InvalidRgbByteBuffer {
/// Expected byte count.
expected: usize,
/// Actual byte count.
actual: usize,
},
/// The input image does not have the dimensions required by a mode.
#[error(
"{mode:?} requires {expected_width}x{expected_height}, got {actual_width}x{actual_height}"
)]
ImageDimensions {
/// Requested SSTV mode.
mode: SstvMode,
/// Required width.
expected_width: u32,
/// Required height.
expected_height: u32,
/// Supplied width.
actual_width: u32,
/// Supplied height.
actual_height: u32,
},
/// A numeric configuration value is invalid.
#[error("invalid configuration: {0}")]
InvalidConfiguration(&'static str),
/// A PCM chunk contained NaN or infinity.
#[error("PCM input contains a non-finite sample")]
NonFiniteSample,
/// Text was supplied after an encoder started its tail or was aborted.
#[error("encoder no longer accepts text")]
EncoderFinished,
/// Samples were supplied after the decoder was finalized.
#[error("decoder has already been finished; call reset before supplying more input")]
DecoderFinished,
}