pub enum CanError {
Show 22 variants
BackendNotFound {
name: String,
},
BackendAlreadyRegistered {
name: String,
},
InitializationFailed {
reason: String,
},
DeviceNotFound {
device: String,
},
ChannelNotFound {
channel: u8,
max: u8,
},
ChannelAlreadyOpen {
channel: u8,
},
ChannelNotOpen {
channel: u8,
},
InvalidId {
value: u32,
max: u32,
},
InvalidDataLength {
expected: usize,
actual: usize,
},
InvalidFormat {
reason: String,
},
ConfigError {
reason: String,
},
InvalidParameter {
parameter: String,
reason: String,
},
VersionIncompatible {
backend_version: String,
expected_version: String,
},
Timeout {
timeout_ms: u64,
},
InsufficientResources {
resource: String,
},
PermissionDenied {
operation: String,
},
SendFailed {
reason: String,
},
ReceiveFailed {
reason: String,
},
BusError {
kind: BusErrorKind,
},
UnsupportedFeature {
feature: String,
},
InvalidState {
expected: String,
current: String,
},
Other {
message: String,
},
}Expand description
Unified CAN error type.
This enum represents all possible errors that can occur when working with CAN hardware through the abstraction layer. Error codes are organized into ranges:
- 1000-1999: Hardware-related errors
- 2000-2999: Protocol-related errors
- 3000-3999: Configuration-related errors
- 4000-4999: System-related errors
§Examples
use canlink_hal::CanError;
let err = CanError::InvalidId { value: 0x800, max: 0x7FF };
assert!(matches!(err, CanError::InvalidId { .. }));Variants§
BackendNotFound
Backend not found (1001)
BackendAlreadyRegistered
Backend already registered (1002)
InitializationFailed
Backend initialization failed (1003)
DeviceNotFound
Device not found (1004)
ChannelNotFound
Channel not found (1005)
ChannelAlreadyOpen
Channel already open (1006)
ChannelNotOpen
Channel not open (1007)
InvalidId
Invalid CAN ID (2001)
InvalidDataLength
Invalid data length (2002)
InvalidFormat
Invalid message format (2003)
ConfigError
Configuration error (3001)
InvalidParameter
Invalid parameter (3002)
VersionIncompatible
Version incompatible (3003)
Timeout
Operation timed out (4001)
InsufficientResources
Insufficient resources (4002)
PermissionDenied
Permission denied (4003)
SendFailed
Send operation failed
ReceiveFailed
Receive operation failed
BusError
Bus error occurred
Fields
kind: BusErrorKindType of bus error
UnsupportedFeature
Feature not supported by hardware
InvalidState
Backend is in wrong state for operation
Other
Other error
Trait Implementations§
Source§impl Error for CanError
impl Error for CanError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()