fxa_client/state_machine/
display.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5//! Display impls for state machine types
6//!
7//! These are sent to Sentry, so they must not leak PII.
8//! In general this means they don't output values for inner fields.
9//!
10//! Also, they must not use the string "auth" since Sentry will filter that out.
11//! Use "ath" instead.
12
13use super::{internal_machines, FxaEvent, FxaState};
14use std::fmt;
15
16impl fmt::Display for FxaState {
17    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
18        let name = match self {
19            Self::Uninitialized => "Uninitialized",
20            Self::Disconnected => "Disconnected",
21            Self::Authenticating { .. } => "Athenticating",
22            Self::Connected => "Connected",
23            Self::AuthIssues => "AthIssues",
24        };
25        write!(f, "{name}")
26    }
27}
28
29impl fmt::Display for FxaEvent {
30    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31        let name = match self {
32            Self::Initialize { .. } => "Initialize",
33            Self::BeginOAuthFlow { .. } => "BeginOAthFlow",
34            Self::BeginPairingFlow { .. } => "BeginPairingFlow",
35            Self::CompleteOAuthFlow { .. } => "CompleteOAthFlow",
36            Self::CancelOAuthFlow => "CancelOAthFlow",
37            Self::CheckAuthorizationStatus => "CheckAuthorizationStatus",
38            Self::Disconnect => "Disconnect",
39            Self::CallGetProfile => "CallGetProfile",
40        };
41        write!(f, "{name}")
42    }
43}
44
45impl fmt::Display for internal_machines::State {
46    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
47        match self {
48            Self::GetAuthState => write!(f, "GetAthState"),
49            Self::BeginOAuthFlow { .. } => write!(f, "BeginOAthFlow"),
50            Self::BeginPairingFlow { .. } => write!(f, "BeginPairingFlow"),
51            Self::CompleteOAuthFlow { .. } => write!(f, "CompleteOAthFlow"),
52            Self::InitializeDevice => write!(f, "InitializeDevice"),
53            Self::EnsureDeviceCapabilities => write!(f, "EnsureDeviceCapabilities"),
54            Self::CheckAuthorizationStatus => write!(f, "CheckAuthorizationStatus"),
55            Self::Disconnect => write!(f, "Disconnect"),
56            Self::GetProfile => write!(f, "GetProfile"),
57            Self::Complete(state) => write!(f, "Complete({state})"),
58            Self::Cancel => write!(f, "Cancel"),
59        }
60    }
61}
62
63impl fmt::Display for internal_machines::Event {
64    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
65        let name = match self {
66            Self::GetAuthStateSuccess { .. } => "GetAthStateSuccess",
67            Self::BeginOAuthFlowSuccess { .. } => "BeginOAthFlowSuccess",
68            Self::BeginPairingFlowSuccess { .. } => "BeginPairingFlowSuccess",
69            Self::CompleteOAuthFlowSuccess => "CompleteOAthFlowSuccess",
70            Self::InitializeDeviceSuccess => "InitializeDeviceSuccess",
71            Self::EnsureDeviceCapabilitiesSuccess => "EnsureDeviceCapabilitiesSuccess",
72            Self::CheckAuthorizationStatusSuccess { .. } => "CheckAuthorizationStatusSuccess",
73            Self::DisconnectSuccess => "DisconnectSuccess",
74            Self::GetProfileSuccess => "GetProfileSuccess",
75            Self::CallError => "CallError",
76            Self::EnsureCapabilitiesAuthError => "EnsureCapabilitiesAthError",
77        };
78        write!(f, "{name}")
79    }
80}