Skip to main content

oxigdal_streaming/
error.rs

1//! Error types for the streaming module.
2
3#[cfg(not(feature = "std"))]
4use alloc::string::String;
5
6/// Result type for streaming operations.
7pub type Result<T> = core::result::Result<T, StreamingError>;
8
9/// Errors that can occur during streaming operations.
10#[derive(Debug, thiserror::Error)]
11pub enum StreamingError {
12    /// Core OxiGDAL error
13    #[cfg(feature = "std")]
14    #[error("OxiGDAL error: {0}")]
15    Core(#[from] oxigdal_core::error::OxiGdalError),
16
17    /// Stream is closed
18    #[error("Stream is closed")]
19    StreamClosed,
20
21    /// Stream buffer full
22    #[error("Stream buffer is full")]
23    BufferFull,
24
25    /// Invalid window configuration
26    #[error("Invalid window configuration: {0}")]
27    InvalidWindow(String),
28
29    /// Watermark error
30    #[error("Watermark error: {0}")]
31    WatermarkError(String),
32
33    /// State error
34    #[error("State error: {0}")]
35    StateError(String),
36
37    /// Checkpoint error
38    #[error("Checkpoint error: {0}")]
39    CheckpointError(String),
40
41    /// Partition error
42    #[error("Partition error: {0}")]
43    PartitionError(String),
44
45    /// Join error
46    #[error("Join error: {0}")]
47    JoinError(String),
48
49    /// Serialization error
50    #[error("Serialization error: {0}")]
51    SerializationError(String),
52
53    /// Deserialization error
54    #[error("Deserialization error: {0}")]
55    DeserializationError(String),
56
57    /// RocksDB error
58    #[cfg(feature = "rocksdb-backend")]
59    #[error("RocksDB error: {0}")]
60    RocksDB(#[from] rocksdb::Error),
61
62    /// IO error
63    #[cfg(feature = "std")]
64    #[error("IO error: {0}")]
65    Io(#[from] std::io::Error),
66
67    /// Arrow error
68    #[cfg(feature = "std")]
69    #[error("Arrow error: {0}")]
70    Arrow(#[from] arrow::error::ArrowError),
71
72    /// Send error
73    #[error("Channel send error")]
74    SendError,
75
76    /// Receive error
77    #[error("Channel receive error")]
78    RecvError,
79
80    /// Timeout error
81    #[error("Operation timed out")]
82    Timeout,
83
84    /// Invalid state
85    #[error("Invalid state: {0}")]
86    InvalidState(String),
87
88    /// Configuration error
89    #[error("Configuration error: {0}")]
90    ConfigError(String),
91
92    /// Invalid operation
93    #[error("Invalid operation: {0}")]
94    InvalidOperation(String),
95
96    /// Not implemented
97    #[error("Not implemented: {0}")]
98    NotImplemented(String),
99
100    /// Other error
101    #[error("Other error: {0}")]
102    Other(String),
103}
104
105#[cfg(feature = "std")]
106impl<T> From<crossbeam_channel::SendError<T>> for StreamingError {
107    fn from(_: crossbeam_channel::SendError<T>) -> Self {
108        StreamingError::SendError
109    }
110}
111
112#[cfg(feature = "std")]
113impl From<crossbeam_channel::RecvError> for StreamingError {
114    fn from(_: crossbeam_channel::RecvError) -> Self {
115        StreamingError::RecvError
116    }
117}
118
119#[cfg(feature = "std")]
120impl From<serde_json::Error> for StreamingError {
121    fn from(e: serde_json::Error) -> Self {
122        StreamingError::SerializationError(e.to_string())
123    }
124}