pub enum EolAction {
Trash,
Delete,
}Expand description
Represents the action to take on Gmail messages that meet end-of-life criteria.
This enum defines the two possible actions for handling messages when they reach the end of their lifecycle based on configured retention rules.
§Variants
Trash- Move messages to Gmail’s trash folder (default, reversible)Delete- Permanently delete messages (irreversible)
§Default Behavior
The default action is Trash, which provides a safety net
by allowing message recovery from the trash folder.
§Examples
use cull_gmail::EolAction;
// Using the default (Trash)
let safe_action = EolAction::default();
assert_eq!(safe_action, EolAction::Trash);
// Comparing actions
let delete = EolAction::Delete;
let trash = EolAction::Trash;
assert_ne!(delete, trash);
// Converting to string for logging/display
println!("Action: {}", delete); // Prints: "delete"Variants§
Trash
Move the message to Gmail’s trash folder.
This is the default and safer option as it allows message recovery. Messages in the trash are automatically deleted by Gmail after 30 days.
§Safety
This action is reversible - messages can be recovered from the trash folder until they are automatically purged or manually deleted from trash.
Delete
Permanently delete the message immediately.
This action bypasses the trash folder and permanently removes the message.
§Warning
This action is irreversible. Once deleted, messages cannot be recovered. Use with extreme caution and thorough testing of rule criteria.
§Use Cases
- Sensitive data that should not remain in trash
- Storage optimization where trash recovery is not needed
- Automated cleanup of known disposable messages
Implementations§
Source§impl EolAction
impl EolAction
Sourcepub fn parse(input: &str) -> Option<Self>
pub fn parse(input: &str) -> Option<Self>
Parses a string into an EolAction variant.
This method provides case-insensitive parsing from string representations
to EolAction variants. It’s useful for configuration file parsing,
command-line arguments, and user input validation.
§Arguments
input- A string slice to parse. Case is ignored.
§Returns
Some(EolAction)if the string matches a valid variantNoneif the string is not recognized
§Valid Input Strings
"trash","Trash","TRASH"→EolAction::Trash"delete","Delete","DELETE"→EolAction::Delete
§Examples
use cull_gmail::EolAction;
// Valid parsing (case-insensitive)
assert_eq!(EolAction::parse("trash"), Some(EolAction::Trash));
assert_eq!(EolAction::parse("TRASH"), Some(EolAction::Trash));
assert_eq!(EolAction::parse("Delete"), Some(EolAction::Delete));
// Invalid input
assert_eq!(EolAction::parse("invalid"), None);
assert_eq!(EolAction::parse(""), None);§Use Cases
use cull_gmail::EolAction;
fn parse_user_action(input: &str) -> Result<EolAction, String> {
EolAction::parse(input)
.ok_or_else(|| format!("Invalid action: '{}'. Use 'trash' or 'delete'.", input))
}
assert!(parse_user_action("trash").is_ok());
assert!(parse_user_action("invalid").is_err());Sourcepub fn is_reversible(&self) -> bool
pub fn is_reversible(&self) -> bool
Returns true if the action is reversible (can be undone).
This method helps determine if an action allows for message recovery, which is useful for safety checks and user confirmations.
§Returns
trueforEolAction::Trash(messages can be recovered from trash)falseforEolAction::Delete(messages are permanently deleted)
§Examples
use cull_gmail::EolAction;
assert!(EolAction::Trash.is_reversible());
assert!(!EolAction::Delete.is_reversible());
// Use in safety checks
let action = EolAction::Delete;
if !action.is_reversible() {
println!("Warning: This action cannot be undone!");
}Sourcepub fn variants() -> &'static [EolAction]
pub fn variants() -> &'static [EolAction]
Returns all possible EolAction variants.
This method is useful for generating help text, validation lists, or iterating over all possible actions.
§Returns
An array containing all EolAction variants in declaration order.
§Examples
use cull_gmail::EolAction;
let all_actions = EolAction::variants();
assert_eq!(all_actions.len(), 2);
assert_eq!(all_actions[0], EolAction::Trash);
assert_eq!(all_actions[1], EolAction::Delete);
// Generate help text
println!("Available actions:");
for action in EolAction::variants() {
println!(" {} - {}", action,
if action.is_reversible() { "reversible" } else { "irreversible" });
}Trait Implementations§
Source§impl Display for EolAction
impl Display for EolAction
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the EolAction as a lowercase string.
This implementation provides a consistent string representation for logging, configuration, and user interfaces.
§Returns
"trash"forEolAction::Trash"delete"forEolAction::Delete
§Examples
use cull_gmail::EolAction;
assert_eq!(EolAction::Trash.to_string(), "trash");
assert_eq!(EolAction::Delete.to_string(), "delete");
// Useful for logging
let action = EolAction::default();
println!("Performing action: {}", action);impl Copy for EolAction
impl Eq for EolAction
impl StructuralPartialEq for EolAction
Auto Trait Implementations§
impl Freeze for EolAction
impl RefUnwindSafe for EolAction
impl Send for EolAction
impl Sync for EolAction
impl Unpin for EolAction
impl UnwindSafe for EolAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more