feat: impl TryFrom<String> for NonSpecialMessage that avoids cloning

This commit is contained in:
2026-07-08 14:28:01 -04:00
parent 239ae331cd
commit 22c5009d95

View File

@@ -70,6 +70,19 @@ impl FromStr for NonSpecialMessage {
}
}
impl TryFrom<String> for NonSpecialMessage {
type Error = WasSpecialMessage;
fn try_from(s: String) -> Result<Self, Self::Error> {
match SpecialMessage::from_str(&s) {
Ok(special_message) => Err(WasSpecialMessage {
got: special_message,
}),
Err(_e) => Ok(NonSpecialMessage(s)),
}
}
}
/// How much of a notification is visible on the lock screen
#[derive(Debug, Clone, Default, EnumString, strum::Display)]
#[strum(serialize_all = "snake_case")]