Files
cull-gmail/src/eol_action.rs
Jeremiah Russell 5a1f834a4f feat(eol_action): add clone derive to eolaction enum
- add clone derive to eolaction enum for easier usage and manipulation
2025-10-14 07:41:39 +01:00

34 lines
948 B
Rust

use std::fmt;
/// End of life action
/// - Trash - move the message to the trash to be automatically deleted by Google
/// - Delete - delete the message immediately without allowing rescue from trash
#[derive(Debug, Default, Clone)]
pub enum EolAction {
#[default]
/// Move the message to the trash
Trash,
/// Delete the message immediately
Delete,
}
impl fmt::Display for EolAction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EolAction::Trash => write!(f, "trash"),
EolAction::Delete => write!(f, "delete"),
}
}
}
impl EolAction {
/// Parse a string to a valid `EolAction` variant or return `None`.
pub fn parse(str: &str) -> Option<EolAction> {
match str.to_lowercase().as_str() {
"trash" => Some(EolAction::Trash),
"delete" => Some(EolAction::Delete),
_ => None,
}
}
}