aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/pinentry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'nitrocli/src/pinentry.rs')
-rw-r--r--nitrocli/src/pinentry.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs
index 33b5266..0d9fc5f 100644
--- a/nitrocli/src/pinentry.rs
+++ b/nitrocli/src/pinentry.rs
@@ -17,7 +17,9 @@
// * along with this program. If not, see <http://www.gnu.org/licenses/>. *
// *************************************************************************
+use std::fmt;
use std::process;
+use std::str;
use crate::error::Error;
@@ -33,6 +35,31 @@ pub enum PinType {
User,
}
+impl fmt::Display for PinType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(
+ f,
+ "{}",
+ match *self {
+ PinType::Admin => "admin",
+ PinType::User => "user",
+ }
+ )
+ }
+}
+
+impl str::FromStr for PinType {
+ type Err = ();
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ "admin" => Ok(PinType::Admin),
+ "user" => Ok(PinType::User),
+ _ => Err(()),
+ }
+ }
+}
+
impl PinType {
fn cache_id(self) -> &'static str {
match self {