mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
feat: add redis cache to usercheck/nb responses (#7316)
* feat: add redis cache to usercheck responses * feat: add redis cache to neverbounce responses
This commit is contained in:
@@ -165,6 +165,18 @@ pub enum VerificationResult {
|
||||
}
|
||||
|
||||
impl VerificationResult {
|
||||
#[must_use]
|
||||
pub fn from_api_value(value: &str) -> Self {
|
||||
match value {
|
||||
"valid" => Self::Valid,
|
||||
"invalid" => Self::Invalid,
|
||||
"disposable" => Self::Disposable,
|
||||
"catchall" => Self::CatchAll,
|
||||
"unknown" => Self::Unknown,
|
||||
value => Self::Unrecognized(value.to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self {
|
||||
VerificationResult::Valid => "valid",
|
||||
@@ -182,14 +194,7 @@ impl<'de> Deserialize<'de> for VerificationResult {
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
Ok(match String::deserialize(deserializer)?.as_str() {
|
||||
"valid" => Self::Valid,
|
||||
"invalid" => Self::Invalid,
|
||||
"disposable" => Self::Disposable,
|
||||
"catchall" => Self::CatchAll,
|
||||
"unknown" => Self::Unknown,
|
||||
value => Self::Unrecognized(value.to_owned()),
|
||||
})
|
||||
Ok(Self::from_api_value(&String::deserialize(deserializer)?))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user