-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
156 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::{display, nfc}; | ||
use core::fmt; | ||
|
||
/// Main error type | ||
#[derive(Debug)] | ||
#[allow(clippy::enum_variant_names)] | ||
pub enum Error { | ||
/// Display output error | ||
DisplayError(display::Error), | ||
/// NFC reader error | ||
NFCError(nfc::Error), | ||
/// User cancel request | ||
Cancel, | ||
/// User interaction timeout | ||
UserTimeout, | ||
/// No network connection | ||
NoNetwork, | ||
} | ||
|
||
impl From<display::Error> for Error { | ||
fn from(err: display::Error) -> Self { | ||
Self::DisplayError(err) | ||
} | ||
} | ||
|
||
impl From<nfc::Error> for Error { | ||
fn from(err: nfc::Error) -> Self { | ||
Self::NFCError(err) | ||
} | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Self::DisplayError(err) => write!(f, "Display: {err}"), | ||
Self::NFCError(err) => write!(f, "NFC: {err}"), | ||
Self::Cancel => write!(f, "User cancelled"), | ||
Self::UserTimeout => write!(f, "Timeout waiting for input"), | ||
Self::NoNetwork => write!(f, "No network connection"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters