EolAction

Enum EolAction 

Source
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

Source

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 variant
  • None if the string is not recognized
§Valid Input Strings
§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());
Source

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
§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!");
}
Source

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 Clone for EolAction

Source§

fn clone(&self) -> EolAction

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EolAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EolAction

Source§

fn default() -> EolAction

Returns the “default value” for a type. Read more
Source§

impl Display for EolAction

Source§

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
§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);
Source§

impl Hash for EolAction

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EolAction

Source§

fn eq(&self, other: &EolAction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for EolAction

Source§

impl Eq for EolAction

Source§

impl StructuralPartialEq for EolAction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,