Files
cull-gmail/src/eol_action.rs
Jeremiah Russell 74512bdea3 test(rules): add unit tests covering all public methods and edge cases
- Add comprehensive test coverage for all Rules public methods
- Test both success and error paths with proper assertions
- Add PartialEq derive to EolAction to enable comparisons in tests
- Include edge cases like duplicate labels and nonexistent IDs
- Mark file system integration tests as ignore to avoid interference
2025-10-19 08:52:23 +01:00

34 lines
959 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, PartialEq)]
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,
}
}
}