Skip to main content

VacationTracker

Struct VacationTracker 

Source
pub struct VacationTracker { /* private fields */ }
Expand description

In-memory ledger for vacation respond-once-per-sender-per-period semantics (RFC 5230). Record a reply when one is sent; query with seen_before to decide whether another is due. Thread-safe; usable directly as an EvalContext::seen_before predicate.

use sieve_kit::actions::VacationTracker;

let tracker = VacationTracker::new();
assert!(!tracker.seen_before("alice@example.com", 7));
tracker.record("alice@example.com");
assert!(tracker.seen_before("alice@example.com", 7));
assert!(!tracker.seen_before("bob@example.com", 7));

Implementations§

Source§

impl VacationTracker

Source

pub fn new() -> Self

Create an empty tracker.

Source

pub fn seen_before(&self, sender: &str, days: u32) -> bool

Whether a reply was recorded for sender less than days days ago. Poisoned state is treated as “nothing recorded” (never panics).

Source

pub fn record(&self, sender: &str)

Record that a reply was sent to sender, effective now.

Source

pub fn record_at(&self, sender: &str, at: Instant)

Record a reply with an explicit timestamp — the injection point for tests and clock-control.

Trait Implementations§

Source§

impl Default for VacationTracker

Source§

fn default() -> VacationTracker

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.