git_bug/entities/identity/snapshot/
history_step.rs1use url::Url;
15
16use crate::replica::entity::{
17 identity::IdentityStub, snapshot::timeline::history_step::HistoryStep, timestamp::TimeStamp,
18};
19
20#[derive(Debug, Clone)]
22pub enum IdentityHistoryStep {
23 Name(NameHistoryStep),
25
26 Email(EmailHistoryStep),
28
29 LoginName(LoginNameHistoryStep),
31
32 AvatarUrl(AvatarUrlHistoryStep),
34
35 Metadata(MetadataHistoryStep),
37}
38
39impl HistoryStep for IdentityHistoryStep {
40 fn author(&self) -> IdentityStub {
41 match self {
42 IdentityHistoryStep::Name(a) => a.author,
43 IdentityHistoryStep::Email(a) => a.author,
44 IdentityHistoryStep::LoginName(a) => a.author,
45 IdentityHistoryStep::AvatarUrl(a) => a.author,
46 IdentityHistoryStep::Metadata(a) => a.author,
47 }
48 }
49
50 fn at(&self) -> TimeStamp {
51 match self {
52 IdentityHistoryStep::Name(name_history_step) => name_history_step.at,
53 IdentityHistoryStep::Email(email_history_step) => email_history_step.at,
54 IdentityHistoryStep::LoginName(login_name_history_step) => login_name_history_step.at,
55 IdentityHistoryStep::AvatarUrl(avatar_url_history_step) => avatar_url_history_step.at,
56 IdentityHistoryStep::Metadata(metadata_history_step) => metadata_history_step.at,
57 }
58 }
59}
60
61#[derive(Debug, Clone)]
63pub struct NameHistoryStep {
64 pub author: IdentityStub,
66
67 pub name: String,
69
70 pub at: TimeStamp,
72}
73
74#[derive(Debug, Clone)]
76pub struct EmailHistoryStep {
77 pub author: IdentityStub,
79
80 pub email: String,
82
83 pub at: TimeStamp,
85}
86
87#[derive(Debug, Clone)]
90pub struct LoginNameHistoryStep {
91 pub author: IdentityStub,
93
94 pub login_name: String,
96
97 pub at: TimeStamp,
99}
100
101#[derive(Debug, Clone)]
104pub struct AvatarUrlHistoryStep {
105 pub author: IdentityStub,
107
108 pub avatar_url: Url,
110
111 pub at: TimeStamp,
113}
114
115#[derive(Debug, Clone)]
118pub struct MetadataHistoryStep {
119 pub author: IdentityStub,
121
122 pub metadata: Vec<(String, String)>,
124
125 pub at: TimeStamp,
127}