Merge pull request #162 from dyc3/from-reader
add SteamGuardAccount::from_reader
This commit is contained in:
commit
db6557ca0d
2 changed files with 12 additions and 1 deletions
|
@ -125,6 +125,10 @@ where
|
||||||
pub(crate) fn prompt_confirmation_menu(
|
pub(crate) fn prompt_confirmation_menu(
|
||||||
confirmations: Vec<Confirmation>,
|
confirmations: Vec<Confirmation>,
|
||||||
) -> anyhow::Result<(Vec<Confirmation>, Vec<Confirmation>)> {
|
) -> anyhow::Result<(Vec<Confirmation>, Vec<Confirmation>)> {
|
||||||
|
if confirmations.len() == 0 {
|
||||||
|
bail!("no confirmations")
|
||||||
|
}
|
||||||
|
|
||||||
let mut to_accept_idx: HashSet<usize> = HashSet::new();
|
let mut to_accept_idx: HashSet<usize> = HashSet::new();
|
||||||
let mut to_deny_idx: HashSet<usize> = HashSet::new();
|
let mut to_deny_idx: HashSet<usize> = HashSet::new();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use reqwest::{
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
pub use secrecy::{ExposeSecret, SecretString};
|
pub use secrecy::{ExposeSecret, SecretString};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::HashMap, convert::TryInto};
|
use std::{collections::HashMap, convert::TryInto, io::Read};
|
||||||
use steamapi::SteamApiClient;
|
use steamapi::SteamApiClient;
|
||||||
pub use userlogin::{LoginError, UserLogin};
|
pub use userlogin::{LoginError, UserLogin};
|
||||||
#[macro_use]
|
#[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) {
|
pub fn set_session(&mut self, session: steamapi::Session) {
|
||||||
self.session = Some(session.into());
|
self.session = Some(session.into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue