1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

//! Display impls for state machine types
//!
//! These are sent to Sentry, so they must not leak PII.
//! In general this means they don't output values for inner fields.
//!
//! Also, they must not use the string "auth" since Sentry will filter that out.
//! Use "ath" instead.

use super::{internal_machines, FxaEvent, FxaState};
use std::fmt;

impl fmt::Display for FxaState {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let name = match self {
            Self::Uninitialized => "Uninitialized",
            Self::Disconnected => "Disconnected",
            Self::Authenticating { .. } => "Athenticating",
            Self::Connected => "Connected",
            Self::AuthIssues => "AthIssues",
        };
        write!(f, "{name}")
    }
}

impl fmt::Display for FxaEvent {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let name = match self {
            Self::Initialize { .. } => "Initialize",
            Self::BeginOAuthFlow { .. } => "BeginOAthFlow",
            Self::BeginPairingFlow { .. } => "BeginPairingFlow",
            Self::CompleteOAuthFlow { .. } => "CompleteOAthFlow",
            Self::CancelOAuthFlow => "CancelOAthFlow",
            Self::CheckAuthorizationStatus => "CheckAthorizationStatus",
            Self::Disconnect => "Disconnect",
            Self::CallGetProfile => "CallGetProfile",
        };
        write!(f, "{name}")
    }
}

impl fmt::Display for internal_machines::State {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Self::GetAuthState => write!(f, "GetAthState"),
            Self::BeginOAuthFlow { .. } => write!(f, "BeginOAthFlow"),
            Self::BeginPairingFlow { .. } => write!(f, "BeginPairingFlow"),
            Self::CompleteOAuthFlow { .. } => write!(f, "CompleteOAthFlow"),
            Self::InitializeDevice => write!(f, "InitializeDevice"),
            Self::EnsureDeviceCapabilities => write!(f, "EnsureDeviceCapabilities"),
            Self::CheckAuthorizationStatus => write!(f, "CheckAthorizationStatus"),
            Self::Disconnect => write!(f, "Disconnect"),
            Self::GetProfile => write!(f, "GetProfile"),
            Self::Complete(state) => write!(f, "Complete({state})"),
            Self::Cancel => write!(f, "Cancel"),
        }
    }
}

impl fmt::Display for internal_machines::Event {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let name = match self {
            Self::GetAuthStateSuccess { .. } => "GetAthStateSuccess",
            Self::BeginOAuthFlowSuccess { .. } => "BeginOAthFlowSuccess",
            Self::BeginPairingFlowSuccess { .. } => "BeginPairingFlowSuccess",
            Self::CompleteOAuthFlowSuccess => "CompleteOAthFlowSuccess",
            Self::InitializeDeviceSuccess => "InitializeDeviceSuccess",
            Self::EnsureDeviceCapabilitiesSuccess => "EnsureDeviceCapabilitiesSuccess",
            Self::CheckAuthorizationStatusSuccess { .. } => "CheckAthorizationStatusSuccess",
            Self::DisconnectSuccess => "DisconnectSuccess",
            Self::GetProfileSuccess => "GetProfileSuccess",
            Self::CallError => "CallError",
            Self::EnsureCapabilitiesAuthError => "EnsureCapabilitiesAthError",
        };
        write!(f, "{name}")
    }
}