pub trait NrcError: Into<u8> + core::fmt::Debug {
fn service_not_supported() -> Self;
fn sub_function_not_supported() -> Self;
fn incorrect_message_length_or_invalid_format() -> Self;
fn conditions_not_correct() -> Self;
fn request_sequence_error() -> Self;
fn request_out_of_range() -> Self;
fn security_access_denied() -> Self;
fn invalid_key() -> Self;
fn exceeded_number_of_attempts() -> Self;
fn required_time_delay_not_expired() -> Self;
fn upload_download_not_accepted() -> Self;
fn transfer_data_suspended() -> Self;
fn general_programming_failure() -> Self;
fn wrong_block_sequence_counter() -> Self;
fn response_pending() -> Self;
fn sub_function_not_supported_in_active_session() -> Self;
fn service_not_supported_in_active_session() -> Self;
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum BuiltinNrc {
ServiceNotSupported = 0x11,
SubFunctionNotSupported = 0x12,
IncorrectMessageLengthOrInvalidFormat = 0x13,
ConditionsNotCorrect = 0x22,
RequestSequenceError = 0x24,
RequestOutOfRange = 0x31,
SecurityAccessDenied = 0x33,
InvalidKey = 0x35,
ExceededNumberOfAttempts = 0x36,
RequiredTimeDelayNotExpired = 0x37,
UploadDownloadNotAccepted = 0x70,
TransferDataSuspended = 0x71,
GeneralProgrammingFailure = 0x72,
WrongBlockSequenceCounter = 0x73,
ResponsePending = 0x78,
SubFunctionNotSupportedInActiveSession = 0x7E,
ServiceNotSupportedInActiveSession = 0x7F,
}
impl From<BuiltinNrc> for u8 {
fn from(n: BuiltinNrc) -> u8 {
n as u8
}
}
impl NrcError for BuiltinNrc {
fn service_not_supported() -> Self {
Self::ServiceNotSupported
}
fn sub_function_not_supported() -> Self {
Self::SubFunctionNotSupported
}
fn incorrect_message_length_or_invalid_format() -> Self {
Self::IncorrectMessageLengthOrInvalidFormat
}
fn conditions_not_correct() -> Self {
Self::ConditionsNotCorrect
}
fn request_sequence_error() -> Self {
Self::RequestSequenceError
}
fn request_out_of_range() -> Self {
Self::RequestOutOfRange
}
fn security_access_denied() -> Self {
Self::SecurityAccessDenied
}
fn invalid_key() -> Self {
Self::InvalidKey
}
fn exceeded_number_of_attempts() -> Self {
Self::ExceededNumberOfAttempts
}
fn required_time_delay_not_expired() -> Self {
Self::RequiredTimeDelayNotExpired
}
fn upload_download_not_accepted() -> Self {
Self::UploadDownloadNotAccepted
}
fn transfer_data_suspended() -> Self {
Self::TransferDataSuspended
}
fn general_programming_failure() -> Self {
Self::GeneralProgrammingFailure
}
fn wrong_block_sequence_counter() -> Self {
Self::WrongBlockSequenceCounter
}
fn response_pending() -> Self {
Self::ResponsePending
}
fn sub_function_not_supported_in_active_session() -> Self {
Self::SubFunctionNotSupportedInActiveSession
}
fn service_not_supported_in_active_session() -> Self {
Self::ServiceNotSupportedInActiveSession
}
}