steamguard-cli/steamguard/src/confirmation.rs

39 lines
928 B
Rust
Raw Normal View History

/// A mobile confirmation. There are multiple things that can be confirmed, like trade offers.
2021-08-14 18:16:40 +02:00
#[derive(Debug, Clone, PartialEq)]
pub struct Confirmation {
2021-08-08 18:54:46 +02:00
pub id: u64,
pub key: u64,
/// Trade offer ID or market transaction ID
pub creator: u64,
pub conf_type: ConfirmationType,
2021-08-14 18:16:40 +02:00
pub description: String,
}
impl Confirmation {
2021-08-08 18:54:46 +02:00
/// Human readable representation of this confirmation.
pub fn description(&self) -> String {
2021-08-14 18:16:40 +02:00
format!("{:?} - {}", self.conf_type, self.description)
2021-08-08 18:54:46 +02:00
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConfirmationType {
2021-08-08 18:54:46 +02:00
Generic = 1,
Trade = 2,
MarketSell = 3,
AccountRecovery = 6,
Unknown,
}
impl From<&str> for ConfirmationType {
2021-08-08 18:54:46 +02:00
fn from(text: &str) -> Self {
match text {
"1" => ConfirmationType::Generic,
"2" => ConfirmationType::Trade,
"3" => ConfirmationType::MarketSell,
"6" => ConfirmationType::AccountRecovery,
_ => ConfirmationType::Unknown,
}
}
}