automotive/
error.rs

1//! Contains the main error type for the library.
2use thiserror::Error;
3
4/// The main error type for the library. Each module has it's own error type that is contained by this error.
5#[derive(Error, Debug, PartialEq, Copy, Clone)]
6pub enum Error {
7    #[error("Not Found")]
8    NotFound,
9    #[error("Not Supported")]
10    NotSupported,
11    #[error("Malformed Frame")]
12    MalformedFrame,
13    #[error("Timeout")]
14    Timeout,
15    #[error("Disconnected")]
16    Disconnected,
17    #[error(transparent)]
18    IsoTPError(#[from] crate::isotp::Error),
19    #[error(transparent)]
20    LibUsbError(#[from] rusb::Error),
21    #[error(transparent)]
22    PandaError(#[from] crate::panda::Error),
23    #[error(transparent)]
24    UDSError(#[from] crate::uds::Error),
25}
26
27impl From<tokio_stream::Elapsed> for Error {
28    fn from(_: tokio_stream::Elapsed) -> Error {
29        Error::Timeout
30    }
31}