use std::fmt::Display; use crate::error::GementionError; pub(crate) enum VerificationStatus { Verified { endpoint: String, source: VerificationSource, }, NotVerified(VerificationFailureReason), } impl ToString for VerificationStatus { fn to_string(&self) -> String { match self { Self::Verified { endpoint, source } => format!("verified: {} [{}]", endpoint, source), Self::NotVerified(failure) => failure.to_string(), } } } #[derive(Debug, Clone, Copy)] pub(crate) enum VerificationSource { Meta, Page, } impl Display for VerificationSource { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Meta => write!(f, "source=meta"), Self::Page => write!(f, "source=page"), } } } pub(crate) enum VerificationFailureReason { /// No titan link to our endpoint exists on this page. NoMentionLinkFound, /// One or more mention links exist, but they are not to this /// endpoint, or for this page. MentionLinkIncorrect, /// There was an error during the verification process. Error(GementionError), } impl ToString for VerificationFailureReason { fn to_string(&self) -> String { match self { Self::NoMentionLinkFound => String::from("No mention link found"), Self::MentionLinkIncorrect => String::from("Mention link points to wrong target"), Self::Error(err) => err.to_string(), } } }