1use core::{
2 fmt::{self, Display, Formatter},
3};
4
5#[repr(u8)]
7#[derive(Debug, Copy, Clone)]
8pub enum ErrorCode {
9 UnsupportedInstruction,
11 HardwareFailure,
13}
14
15impl core::error::Error for ErrorCode {}
16
17impl Display for ErrorCode {
18 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
19 f.write_str(match self {
20 ErrorCode::UnsupportedInstruction => "the hardware instruction is not supported",
21 ErrorCode::HardwareFailure => "hardware generator failure",
22 })
23 }
24}
25
26#[cfg(test)]
27mod test {
28 use super::ErrorCode;
29 use core::error::Error;
30
31 #[test]
32 fn error_code_send() {
33 fn assert_send<T: Send>() {}
34 assert_send::<ErrorCode>();
35 }
36
37 #[test]
38 fn error_code_sync() {
39 fn assert_sync<T: Sync>() {}
40 assert_sync::<ErrorCode>();
41 }
42
43 #[test]
44 fn error_code_copy() {
45 fn assert_copy<T: Copy>() {}
46 assert_copy::<ErrorCode>();
47 }
48
49 #[test]
50 fn error_code_clone() {
51 fn assert_clone<T: Clone>() {}
52 assert_clone::<ErrorCode>();
53 }
54
55 #[test]
56 fn error_code_error() {
57 fn assert_error<T: Error>() {}
58 assert_error::<ErrorCode>();
59 }
60}