steamguard: add SteamGuardAccount::from_reader

This commit is contained in:
Carson McManus 2022-08-13 09:26:23 -04:00
parent 0d90792c47
commit 9f1d692d6d

View file

@ -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<T>(r: T) -> anyhow::Result<Self>
where
T: Read,
{
Ok(serde_json::from_reader(r)?)
}
pub fn set_session(&mut self, session: steamapi::Session) {
self.session = Some(session.into());
}