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
71
72
73
74
75
76
77
78
79
80
81
//! TAK transport error types
use std::io;
use thiserror::Error;
/// Error types for TAK transport operations
#[derive(Debug, Error)]
pub enum TakError {
/// Connection to TAK server or mesh failed
#[error("Connection failed: {0}")]
ConnectionFailed(String),
/// Authentication with TAK server failed
#[error("Authentication failed: {0}")]
AuthenticationFailed(String),
/// Failed to encode CoT message
#[error("Message encoding failed: {0}")]
EncodingError(String),
/// Failed to decode incoming CoT message
#[error("Message decoding failed: {0}")]
DecodingError(String),
/// Message queue is full, message was dropped
#[error("Queue full, message dropped")]
QueueFull,
/// Operation timed out
#[error("Connection timeout")]
Timeout,
/// TLS/SSL error during connection
#[error("TLS/SSL error: {0}")]
TlsError(String),
/// Low-level I/O error
#[error("IO error: {0}")]
IoError(#[from] io::Error),
/// Transport is not connected
#[error("Not connected")]
NotConnected,
/// Invalid configuration
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
/// Multicast error
#[error("Multicast error: {0}")]
MulticastError(String),
/// Protocol framing error
#[error("Protocol framing error: {0}")]
FramingError(String),
/// Channel closed unexpectedly
#[error("Channel closed")]
ChannelClosed,
}
impl TakError {
/// Check if this error is recoverable (worth retrying)
pub fn is_recoverable(&self) -> bool {
matches!(
self,
TakError::ConnectionFailed(_)
| TakError::Timeout
| TakError::IoError(_)
| TakError::NotConnected
)
}
/// Check if this is an authentication error
pub fn is_auth_error(&self) -> bool {
matches!(
self,
TakError::AuthenticationFailed(_) | TakError::TlsError(_)
)
}
}