Add Result alias (#271)

Adds a `yubikey::Result` alias with `yubikey::Error` as the error type.

Since we only have one `Error` type, this simplifies the return types
where a `Result` is returned.
This commit is contained in:
Tony Arcieri (iqlusion)
2021-07-11 09:44:08 -07:00
committed by GitHub
parent 1051eaf26d
commit de51b0cc46
23 changed files with 210 additions and 223 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ pub struct YubiKeyCli {
impl YubiKeyCli {
/// Print usage information
pub fn print_usage() -> Result<(), io::Error> {
pub fn print_usage() -> io::Result<()> {
let mut stdout = STDOUT.lock();
stdout.reset()?;
+1 -1
View File
@@ -53,7 +53,7 @@ impl ReadersCmd {
index: usize,
name: &str,
serial: Serial,
) -> Result<(), io::Error> {
) -> io::Result<()> {
stream.set_color(ColorSpec::new().set_bold(true))?;
write!(stream, "{:>3}:", index)?;
stream.reset()?;
+1 -1
View File
@@ -51,7 +51,7 @@ impl StatusCmd {
stream: &mut StandardStreamLock<'_>,
name: &str,
value: impl ToString,
) -> Result<(), io::Error> {
) -> io::Result<()> {
stream.set_color(ColorSpec::new().set_bold(true))?;
write!(stream, "{:>12}:", name)?;
stream.reset()?;
+2 -2
View File
@@ -27,7 +27,7 @@ pub fn print_cert_info(
yubikey: &mut YubiKey,
slot: SlotId,
stream: &mut StandardStreamLock<'_>,
) -> Result<(), io::Error> {
) -> io::Result<()> {
let cert = match Certificate::read(yubikey, slot) {
Ok(c) => c,
Err(e) => {
@@ -82,7 +82,7 @@ fn print_cert_attr(
stream: &mut StandardStreamLock<'_>,
name: &str,
value: impl ToString,
) -> Result<(), io::Error> {
) -> io::Result<()> {
stream.set_color(ColorSpec::new().set_bold(true))?;
write!(stream, "{:>12}:", name)?;
stream.reset()?;
+1 -1
View File
@@ -143,7 +143,7 @@ impl Status {
}
/// Print the given message
fn print(self, stream: &StandardStream, msg: impl AsRef<str>) -> Result<(), io::Error> {
fn print(self, stream: &StandardStream, msg: impl AsRef<str>) -> io::Result<()> {
let mut s = stream.lock();
s.reset()?;
s.set_color(ColorSpec::new().set_fg(self.color).set_bold(self.bold))?;