use url::Url;
use crate::replica::entity::{
identity::IdentityStub, snapshot::timeline::history_step::HistoryStep, timestamp::TimeStamp,
};
#[derive(Debug, Clone)]
pub enum IdentityHistoryStep {
Name(NameHistoryStep),
Email(EmailHistoryStep),
LoginName(LoginNameHistoryStep),
AvatarUrl(AvatarUrlHistoryStep),
Metadata(MetadataHistoryStep),
}
impl HistoryStep for IdentityHistoryStep {
fn author(&self) -> IdentityStub {
match self {
IdentityHistoryStep::Name(a) => a.author,
IdentityHistoryStep::Email(a) => a.author,
IdentityHistoryStep::LoginName(a) => a.author,
IdentityHistoryStep::AvatarUrl(a) => a.author,
IdentityHistoryStep::Metadata(a) => a.author,
}
}
fn at(&self) -> TimeStamp {
match self {
IdentityHistoryStep::Name(name_history_step) => name_history_step.at,
IdentityHistoryStep::Email(email_history_step) => email_history_step.at,
IdentityHistoryStep::LoginName(login_name_history_step) => login_name_history_step.at,
IdentityHistoryStep::AvatarUrl(avatar_url_history_step) => avatar_url_history_step.at,
IdentityHistoryStep::Metadata(metadata_history_step) => metadata_history_step.at,
}
}
}
#[derive(Debug, Clone)]
pub struct NameHistoryStep {
pub author: IdentityStub,
pub name: String,
pub at: TimeStamp,
}
#[derive(Debug, Clone)]
pub struct EmailHistoryStep {
pub author: IdentityStub,
pub email: String,
pub at: TimeStamp,
}
#[derive(Debug, Clone)]
pub struct LoginNameHistoryStep {
pub author: IdentityStub,
pub login_name: String,
pub at: TimeStamp,
}
#[derive(Debug, Clone)]
pub struct AvatarUrlHistoryStep {
pub author: IdentityStub,
pub avatar_url: Url,
pub at: TimeStamp,
}
#[derive(Debug, Clone)]
pub struct MetadataHistoryStep {
pub author: IdentityStub,
pub metadata: Vec<(String, String)>,
pub at: TimeStamp,
}