From 9f1d692d6dc7749cbde2bcee00d99faca9a98019 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 13 Aug 2022 09:26:23 -0400 Subject: [PATCH] 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()); }