1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Project: scalo
// File: src/transport/error.rs
// Purpose: Transport error types
// Language: Rust
//
// License: Apache-2.0
// Copyright: (c) 2026 HYPERI PTY LIMITED
use thiserror::Error;
/// Result type for transport operations.
pub type TransportResult<T> = Result<T, TransportError>;
/// Errors that can occur during transport operations.
#[derive(Debug, Error)]
pub enum TransportError {
/// Configuration error (missing or invalid config).
#[error("transport config error: {0}")]
Config(String),
/// Connection error (network, auth, etc.).
#[error("transport connection error: {0}")]
Connection(String),
/// Send operation failed.
#[error("transport send error: {0}")]
Send(String),
/// Receive operation failed.
#[error("transport receive error: {0}")]
Recv(String),
/// Commit/acknowledge operation failed.
#[error("transport commit error: {0}")]
Commit(String),
/// Transport is closed or shutting down.
#[error("transport closed")]
Closed,
/// Timeout waiting for operation.
#[error("transport operation timed out")]
Timeout,
/// Backpressure -- transport cannot accept more messages.
#[error("transport backpressure")]
Backpressure,
/// Internal transport error.
#[error("transport internal error: {0}")]
Internal(String),
/// Admin operation error (topic/partition management).
#[error("transport admin error: {0}")]
Admin(String),
}
impl TransportError {
/// Returns true if this error is recoverable (retry may succeed).
#[must_use]
pub fn is_recoverable(&self) -> bool {
matches!(self, Self::Timeout | Self::Backpressure)
}
/// Returns true if this error indicates the transport is unusable.
#[must_use]
pub fn is_fatal(&self) -> bool {
matches!(self, Self::Closed | Self::Config(_))
}
}