From 0d90792c477d224931ad1555f425a3dda5e3341e Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 4 Aug 2022 23:07:43 -0400 Subject: [PATCH 1/2] add check in prompt_confirmation_menu to make sure confirmations is not empty --- src/tui.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tui.rs b/src/tui.rs index 37b2231..da59d90 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -125,6 +125,10 @@ where pub(crate) fn prompt_confirmation_menu( confirmations: Vec, ) -> anyhow::Result<(Vec, Vec)> { + if confirmations.len() == 0 { + bail!("no confirmations") + } + let mut to_accept_idx: HashSet = HashSet::new(); let mut to_deny_idx: HashSet = HashSet::new(); From 9f1d692d6dc7749cbde2bcee00d99faca9a98019 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 13 Aug 2022 09:26:23 -0400 Subject: [PATCH 2/2] steamguard: add SteamGuardAccount::from_reader --- steamguard/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/steamguard/src/lib.rs b/steamguard/src/lib.rs index 0f02adb..59fb957 100644 --- a/steamguard/src/lib.rs +++ b/steamguard/src/lib.rs @@ -13,7 +13,7 @@ use reqwest::{ use scraper::{Html, Selector}; pub use secrecy::{ExposeSecret, SecretString}; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, convert::TryInto}; +use std::{collections::HashMap, convert::TryInto, io::Read}; use steamapi::SteamApiClient; pub use userlogin::{LoginError, UserLogin}; #[macro_use] @@ -94,6 +94,13 @@ impl SteamGuardAccount { }; } + pub fn from_reader(r: T) -> anyhow::Result + where + T: Read, + { + Ok(serde_json::from_reader(r)?) + } + pub fn set_session(&mut self, session: steamapi::Session) { self.session = Some(session.into()); }