Skip to main content

yscv_video/
error.rs

1use thiserror::Error;
2use yscv_tensor::TensorError;
3
4#[derive(Debug, Clone, PartialEq, Eq, Error)]
5pub enum VideoError {
6    #[error("invalid frame tensor shape: expected [H, W, C], got {got:?}")]
7    InvalidFrameShape { got: Vec<usize> },
8    #[error("unsupported channel count: {channels}; expected 1 or 3")]
9    UnsupportedChannelCount { channels: usize },
10    #[error(
11        "invalid camera resolution: width={width}, height={height}; expected width > 0 and height > 0"
12    )]
13    InvalidCameraResolution { width: u32, height: u32 },
14    #[error("invalid camera fps: {fps}; expected fps > 0")]
15    InvalidCameraFps { fps: u32 },
16    #[error("invalid camera device query `{query}`; expected non-empty value")]
17    InvalidCameraDeviceQuery { query: String },
18    #[error("no camera device matched query `{query}`; run device listing to inspect names")]
19    CameraDeviceNotFound { query: String },
20    #[error(
21        "camera query `{query}` matched multiple devices: {}; refine query",
22        matches.join(", ")
23    )]
24    CameraDeviceAmbiguous { query: String, matches: Vec<String> },
25    #[error("invalid raw frame buffer size: expected {expected} bytes, got {got}")]
26    RawFrameSizeMismatch { expected: usize, got: usize },
27    #[error("invalid normalized output buffer size: expected {expected} f32 values, got {got}")]
28    NormalizedBufferSizeMismatch { expected: usize, got: usize },
29    #[error("native camera backend is disabled; enable `yscv-video` feature `native-camera`")]
30    CameraBackendDisabled,
31    #[error("frame source error: {0}")]
32    Source(String),
33    #[error("codec error: {0}")]
34    Codec(String),
35    #[error("container parse error: {0}")]
36    ContainerParse(String),
37    #[error(transparent)]
38    Tensor(#[from] TensorError),
39}