Skip to main content

parallax/
error.rs

1//! Error types for Parallax.
2
3use thiserror::Error;
4
5/// Result type alias using Parallax's Error.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Main error type for Parallax operations.
9#[derive(Error, Debug)]
10#[non_exhaustive]
11pub enum Error {
12    /// Memory pool is exhausted (no slots available).
13    #[error("memory pool exhausted: no slots available")]
14    PoolExhausted,
15
16    /// Buffer pool error (no pool configured or pool unavailable).
17    #[error("buffer pool error: {0}")]
18    BufferPool(String),
19
20    /// Memory allocation failed.
21    #[error("memory allocation failed: {0}")]
22    AllocationFailed(String),
23
24    /// Invalid memory segment operation.
25    #[error("invalid memory segment: {0}")]
26    InvalidSegment(String),
27
28    /// Buffer validation failed (rkyv).
29    #[error("buffer validation failed: {0}")]
30    ValidationFailed(String),
31
32    /// Invalid caps / type mismatch.
33    #[error("invalid caps: {0}")]
34    InvalidCaps(String),
35
36    /// Configuration error.
37    #[error("configuration error: {0}")]
38    Config(String),
39
40    /// Pipeline error.
41    #[error("pipeline error: {0}")]
42    Pipeline(String),
43
44    /// Element error.
45    #[error("element error: {0}")]
46    Element(String),
47
48    /// I/O error.
49    #[error("I/O error: {0}")]
50    Io(#[from] std::io::Error),
51
52    /// System call error (via rustix).
53    #[error("system error: {0}")]
54    System(#[from] rustix::io::Errno),
55
56    /// Device capture/playback error.
57    #[cfg(any(
58        feature = "pipewire",
59        feature = "libcamera",
60        feature = "screen-capture",
61        feature = "v4l2",
62        feature = "alsa"
63    ))]
64    #[error("device error: {0}")]
65    Device(#[from] crate::elements::device::DeviceError),
66}