Skip to main content

nodedb_bridge/
error.rs

1/// Errors produced by the cross-runtime bridge.
2#[derive(Debug, thiserror::Error)]
3pub enum BridgeError {
4    /// The ring buffer is full and the producer cannot enqueue.
5    /// The caller should yield and retry after the consumer drains.
6    #[error("ring buffer full (capacity: {capacity}, pending: {pending})")]
7    Full { capacity: usize, pending: usize },
8
9    /// The ring buffer is empty and the consumer has nothing to dequeue.
10    #[error("ring buffer empty")]
11    Empty,
12
13    /// The other side of the channel has been dropped.
14    #[error("channel disconnected: {side} side dropped")]
15    Disconnected { side: &'static str },
16
17    /// Backpressure threshold exceeded — the caller must throttle.
18    #[error("backpressure: queue utilization at {percent}% (threshold: {threshold}%)")]
19    Backpressure { percent: u8, threshold: u8 },
20
21    /// Request deadline expired before the Data Plane could process it.
22    #[error("deadline exceeded for request {request_id}")]
23    DeadlineExceeded { request_id: u64 },
24}
25
26pub type Result<T> = std::result::Result<T, BridgeError>;