Skip to main content

steam_user/types/
email.rs

1//! Email management types.
2
3use serde::{Deserialize, Serialize};
4
5/// Parsed wizard page parameters from Steam Help pages.
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct WizardPageParams {
8    /// Session ID for the wizard flow.
9    pub session_id: String,
10    /// Issue-specific parameters.
11    pub issue: WizardIssue,
12    /// Default wizard page parameters extracted from JavaScript.
13    pub default_params: WizardDefaultParams,
14}
15
16/// Issue-specific form fields for the wizard.
17#[derive(Debug, Clone, Default, Serialize, Deserialize)]
18pub struct WizardIssue {
19    /// The 's' parameter (session identifier).
20    pub s: String,
21    /// Reset parameter.
22    pub reset: String,
23    /// Lost parameter.
24    pub lost: String,
25    /// Method parameter (e.g., "8" for mobile confirmation).
26    pub method: String,
27    /// Issue ID.
28    pub issueid: String,
29}
30
31/// Default wizard parameters extracted from JavaScript.
32#[derive(Debug, Clone, Default, Serialize, Deserialize)]
33pub struct WizardDefaultParams {
34    /// Account ID (miniprofile).
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub account: Option<u32>,
37    /// Wizard session token.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub wizard: Option<String>,
40    /// Other parameters that may vary.
41    #[serde(flatten)]
42    pub extra: std::collections::HashMap<String, String>,
43}
44
45/// Result of an email change operation.
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(tag = "status", content = "message")]
48pub enum ChangeEmailResult {
49    /// Email change was successful.
50    Success,
51    /// Email change failed with an error message.
52    Error(String),
53}
54
55impl ChangeEmailResult {
56    /// Returns true if the email change was successful.
57    pub fn is_success(&self) -> bool {
58        matches!(self, ChangeEmailResult::Success)
59    }
60
61    /// Returns the error message if the operation failed.
62    pub fn error_message(&self) -> Option<&str> {
63        match self {
64            ChangeEmailResult::Error(msg) => Some(msg),
65            _ => None,
66        }
67    }
68}
69
70/// Status from polling account recovery confirmation.
71#[derive(Debug, Clone, Deserialize)]
72pub struct AccountRecoveryStatus {
73    /// Whether to continue polling.
74    #[serde(default)]
75    pub r#continue: bool,
76    /// Whether the confirmation was successful.
77    #[serde(default)]
78    pub success: bool,
79    /// Error message if any.
80    #[serde(default)]
81    pub error: Option<String>,
82}
83
84/// Response from submitting a new email.
85#[derive(Debug, Clone, Deserialize)]
86pub struct SubmitEmailResponse {
87    /// Hash/URL for next step if successful.
88    #[serde(default)]
89    pub hash: String,
90    /// Error message if failed.
91    #[serde(rename = "errorMsg", default)]
92    pub error_msg: String,
93    /// Whether to show confirmation dialog.
94    #[serde(default)]
95    pub show_confirmation: bool,
96}
97
98/// Response from confirming new email with OTP.
99#[derive(Debug, Clone, Deserialize)]
100pub struct ConfirmEmailResponse {
101    /// Hash/URL containing result - success if contains
102    /// "HelpWithLoginInfoComplete".
103    #[serde(default)]
104    pub hash: String,
105    /// Error message if failed.
106    #[serde(rename = "errorMsg", default)]
107    pub error_msg: String,
108    /// Whether to show confirmation dialog.
109    #[serde(default)]
110    pub show_confirmation: bool,
111}
112
113/// Response from sending account recovery code.
114#[derive(Debug, Clone, Deserialize)]
115pub struct SendRecoveryCodeResponse {
116    /// Whether the operation was successful.
117    #[serde(default)]
118    pub success: bool,
119}