Set up plugin structure

This commit is contained in:
Jack Grigg
2020-12-31 21:17:35 +00:00
parent 05f7f1b076
commit 0052d91aad
5 changed files with 616 additions and 2 deletions
+31
View File
@@ -0,0 +1,31 @@
use std::fmt;
use std::io;
pub enum Error {
Io(io::Error),
}
impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
Error::Io(e)
}
}
// Rust only supports `fn main() -> Result<(), E: Debug>`, so we implement `Debug`
// manually to provide the error output we want.
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Io(e) => writeln!(f, "Failed to set up YubiKey: {}", e)?,
}
writeln!(f)?;
writeln!(
f,
"[ Did this not do what you expected? Could an error be more useful? ]"
)?;
write!(
f,
"[ Tell us: https://str4d.xyz/age-plugin-yubikey/report ]"
)
}
}