From 49f5194e16db47b6de9847b79840c6fe35e0df8c Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sun, 14 Jul 2019 19:19:04 -0700 Subject: Introduce with_password_safe function Similar to the with_*device functions introduced in a previous change, this change introduces a with_password_safe function that is a short hand for opening the Nitrokey, retrieving a handle to the password safe, and invoking a user-supplied function on it. This function will allow us to prevent life time inference problems caused by passing around a PasswordSafe object, which will contain an additional reference (and with that, lifetime) in nitrokey version 0.4. --- nitrocli/src/error.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nitrocli/src/error.rs') diff --git a/nitrocli/src/error.rs b/nitrocli/src/error.rs index d1eb2eb..c0e7403 100644 --- a/nitrocli/src/error.rs +++ b/nitrocli/src/error.rs @@ -47,6 +47,15 @@ pub enum Error { Error(String), } +impl TryInto for Error { + fn try_into(self) -> Result { + match self { + Error::CommandError(_, err) => Ok(err), + err => Err(err), + } + } +} + impl From<&str> for Error { fn from(s: &str) -> Error { Error::Error(s.to_string()) -- cgit v1.2.1