/// Состояние аутентификации /// /// Отвечает за данные авторизации: /// - Ввод номера телефона /// - Ввод кода подтверждения /// - Ввод пароля (2FA) /// Состояние аутентификации #[derive(Debug, Clone, Default)] pub struct AuthState { /// Введённый номер телефона phone_input: String, /// Введённый код подтверждения code_input: String, /// Введённый пароль (для 2FA) password_input: String, } impl AuthState { /// Создать новое состояние аутентификации pub fn new() -> Self { Self::default() } // === Phone input === pub fn phone_input(&self) -> &str { &self.phone_input } pub fn phone_input_mut(&mut self) -> &mut String { &mut self.phone_input } pub fn set_phone_input(&mut self, input: String) { self.phone_input = input; } pub fn clear_phone_input(&mut self) { self.phone_input.clear(); } // === Code input === pub fn code_input(&self) -> &str { &self.code_input } pub fn code_input_mut(&mut self) -> &mut String { &mut self.code_input } pub fn set_code_input(&mut self, input: String) { self.code_input = input; } pub fn clear_code_input(&mut self) { self.code_input.clear(); } // === Password input === pub fn password_input(&self) -> &str { &self.password_input } pub fn password_input_mut(&mut self) -> &mut String { &mut self.password_input } pub fn set_password_input(&mut self, input: String) { self.password_input = input; } pub fn clear_password_input(&mut self) { self.password_input.clear(); } /// Очистить все поля ввода pub fn clear_all(&mut self) { self.phone_input.clear(); self.code_input.clear(); self.password_input.clear(); } }