Skip to main content

CanError

Enum CanError 

Source
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)

Fields

§name: String

Backend name that was not found

§

BackendAlreadyRegistered

Backend already registered (1002)

Fields

§name: String

Backend name that is already registered

§

InitializationFailed

Backend initialization failed (1003)

Fields

§reason: String

Reason for initialization failure

§

DeviceNotFound

Device not found (1004)

Fields

§device: String

Device identifier

§

ChannelNotFound

Channel not found (1005)

Fields

§channel: u8

Channel number that was requested

§max: u8

Maximum channel number available

§

ChannelAlreadyOpen

Channel already open (1006)

Fields

§channel: u8

Channel number

§

ChannelNotOpen

Channel not open (1007)

Fields

§channel: u8

Channel number

§

InvalidId

Invalid CAN ID (2001)

Fields

§value: u32

The invalid ID value

§max: u32

Maximum allowed ID value

§

InvalidDataLength

Invalid data length (2002)

Fields

§expected: usize

Expected maximum length

§actual: usize

Actual length provided

§

InvalidFormat

Invalid message format (2003)

Fields

§reason: String

Reason for format error

§

ConfigError

Configuration error (3001)

Fields

§reason: String

Reason for configuration error

§

InvalidParameter

Invalid parameter (3002)

Fields

§parameter: String

Parameter name

§reason: String

Reason why parameter is invalid

§

VersionIncompatible

Version incompatible (3003)

Fields

§backend_version: String

Backend version

§expected_version: String

Expected version

§

Timeout

Operation timed out (4001)

Fields

§timeout_ms: u64

Timeout duration in milliseconds

§

InsufficientResources

Insufficient resources (4002)

Fields

§resource: String

Resource that is insufficient

§

PermissionDenied

Permission denied (4003)

Fields

§operation: String

Operation that was denied

§

SendFailed

Send operation failed

Fields

§reason: String

Reason for send failure

§

ReceiveFailed

Receive operation failed

Fields

§reason: String

Reason for receive failure

§

BusError

Bus error occurred

Fields

§kind: BusErrorKind

Type of bus error

§

UnsupportedFeature

Feature not supported by hardware

Fields

§feature: String

Feature that is not supported

§

InvalidState

Backend is in wrong state for operation

Fields

§expected: String

Expected state

§current: String

Current state

§

Other

Other error

Fields

§message: String

Error message

Trait Implementations§

Source§

impl Debug for CanError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CanError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CanError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CanError> for MonitorError

Source§

fn from(source: CanError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.