1pub trait NrcError: Into<u8> + core::fmt::Debug {
10 fn service_not_supported() -> Self;
14 fn sub_function_not_supported() -> Self;
16 fn incorrect_message_length_or_invalid_format() -> Self;
18 fn conditions_not_correct() -> Self;
20 fn request_sequence_error() -> Self;
22 fn request_out_of_range() -> Self;
24 fn security_access_denied() -> Self;
26 fn invalid_key() -> Self;
28 fn exceeded_number_of_attempts() -> Self;
30 fn required_time_delay_not_expired() -> Self;
32 fn upload_download_not_accepted() -> Self;
34 fn transfer_data_suspended() -> Self;
36 fn general_programming_failure() -> Self;
38 fn wrong_block_sequence_counter() -> Self;
40 fn response_pending() -> Self;
42 fn sub_function_not_supported_in_active_session() -> Self;
44 fn service_not_supported_in_active_session() -> Self;
46
47 }
49
50#[derive(Debug, Clone, PartialEq, Eq)]
59#[repr(u8)]
60pub enum BuiltinNrc {
61 ServiceNotSupported = 0x11,
62 SubFunctionNotSupported = 0x12,
63 IncorrectMessageLengthOrInvalidFormat = 0x13,
64 ConditionsNotCorrect = 0x22,
65 RequestSequenceError = 0x24,
66 RequestOutOfRange = 0x31,
67 SecurityAccessDenied = 0x33,
68 InvalidKey = 0x35,
69 ExceededNumberOfAttempts = 0x36,
70 RequiredTimeDelayNotExpired = 0x37,
71 UploadDownloadNotAccepted = 0x70,
72 TransferDataSuspended = 0x71,
73 GeneralProgrammingFailure = 0x72,
74 WrongBlockSequenceCounter = 0x73,
75 ResponsePending = 0x78,
76 SubFunctionNotSupportedInActiveSession = 0x7E,
77 ServiceNotSupportedInActiveSession = 0x7F,
78}
79
80impl From<BuiltinNrc> for u8 {
81 fn from(n: BuiltinNrc) -> u8 {
82 n as u8
83 }
84}
85
86impl NrcError for BuiltinNrc {
87 fn service_not_supported() -> Self {
88 Self::ServiceNotSupported
89 }
90 fn sub_function_not_supported() -> Self {
91 Self::SubFunctionNotSupported
92 }
93 fn incorrect_message_length_or_invalid_format() -> Self {
94 Self::IncorrectMessageLengthOrInvalidFormat
95 }
96 fn conditions_not_correct() -> Self {
97 Self::ConditionsNotCorrect
98 }
99 fn request_sequence_error() -> Self {
100 Self::RequestSequenceError
101 }
102 fn request_out_of_range() -> Self {
103 Self::RequestOutOfRange
104 }
105 fn security_access_denied() -> Self {
106 Self::SecurityAccessDenied
107 }
108 fn invalid_key() -> Self {
109 Self::InvalidKey
110 }
111 fn exceeded_number_of_attempts() -> Self {
112 Self::ExceededNumberOfAttempts
113 }
114 fn required_time_delay_not_expired() -> Self {
115 Self::RequiredTimeDelayNotExpired
116 }
117 fn upload_download_not_accepted() -> Self {
118 Self::UploadDownloadNotAccepted
119 }
120 fn transfer_data_suspended() -> Self {
121 Self::TransferDataSuspended
122 }
123 fn general_programming_failure() -> Self {
124 Self::GeneralProgrammingFailure
125 }
126 fn wrong_block_sequence_counter() -> Self {
127 Self::WrongBlockSequenceCounter
128 }
129 fn response_pending() -> Self {
130 Self::ResponsePending
131 }
132 fn sub_function_not_supported_in_active_session() -> Self {
133 Self::SubFunctionNotSupportedInActiveSession
134 }
135 fn service_not_supported_in_active_session() -> Self {
136 Self::ServiceNotSupportedInActiveSession
137 }
138}
139
140