| 1 |
use displaydoc::Display; |
| 2 |
|
| 3 |
#[derive(Debug, Display)] |
| 4 |
pub enum DataStoreError { |
| 5 |
/// data store disconnected |
| 6 |
Disconnect, |
| 7 |
/// the data for key `{0}` is not available |
| 8 |
Redaction(String), |
| 9 |
/// invalid header (expected {expected:?}, found {found:?}) |
| 10 |
InvalidHeader { expected: String, found: String }, |
| 11 |
/// unknown data store error |
| 12 |
Unknown, |
| 13 |
} |
| 14 |
|
| 15 |
fn main() { |
| 16 |
let disconnect = DataStoreError::Disconnect; |
| 17 |
println!( |
| 18 |
"Enum value `Disconnect` should be printed as:\n\t{}", |
| 19 |
disconnect |
| 20 |
); |
| 21 |
|
| 22 |
let redaction = DataStoreError::Redaction(String::from("Dummy")); |
| 23 |
println!( |
| 24 |
"Enum value `Redaction` should be printed as:\n\t{}", |
| 25 |
redaction |
| 26 |
); |
| 27 |
|
| 28 |
let invalid_header = DataStoreError::InvalidHeader { |
| 29 |
expected: String::from("https"), |
| 30 |
found: String::from("http"), |
| 31 |
}; |
| 32 |
println!( |
| 33 |
"Enum value `InvalidHeader` should be printed as:\n\t{}", |
| 34 |
invalid_header |
| 35 |
); |
| 36 |
} |