Skip to main content

nodedb_bridge/
error.rs

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