pub struct ActivityMonitor {
pub activity_log: Vec<DateTime<Utc>>,
pub detected_sleep_hour: Option<u8>,
pub last_deep_dream: Option<DateTime<Utc>>,
pub deep_dream_cooldown: Duration,
pub deep_dream_inactivity_mins: u64,
}Expand description
Tracks user activity to detect idle periods and ideal times for deep dreaming.
Fields§
§activity_log: Vec<DateTime<Utc>>Sampled activity timestamps (rounded to 10 min, retained 7 days)
detected_sleep_hour: Option<u8>Automatically detected typical sleep hour (0-23)
last_deep_dream: Option<DateTime<Utc>>When the last deep dream was successfully completed
deep_dream_cooldown: DurationMinimum time between deep dreams
deep_dream_inactivity_mins: u64Inactivity threshold (minutes) before deep dream can trigger
Implementations§
Source§impl ActivityMonitor
impl ActivityMonitor
Sourcepub fn record_activity(&mut self)
pub fn record_activity(&mut self)
Record a sample of user activity.
Sourcepub fn compute_sleep_hour(&self) -> Option<u8>
pub fn compute_sleep_hour(&self) -> Option<u8>
Compute the most likely sleep hour from the activity log.
Counts activity samples per UTC hour (0–23) and returns the
hour with the fewest samples — the user is typically away.
Returns None when the log has fewer than 14 entries (insufficient data).
Sourcepub fn should_deep_dream(&self) -> bool
pub fn should_deep_dream(&self) -> bool
Check if deep dream conditions are met.
Returns false if no activity samples exist (fresh install), if within
cooldown since the last deep dream, or if insufficient inactivity time.
When detected_sleep_hour matches the current hour (±2h window),
the inactivity threshold is relaxed to one-third of the configured value
(minimum 10 minutes) since the user is likely away during their sleep window.
Sourcepub fn persistence_path() -> PathBuf
pub fn persistence_path() -> PathBuf
Default path for global activity monitor persistence.
Trait Implementations§
Source§impl Clone for ActivityMonitor
impl Clone for ActivityMonitor
Source§fn clone(&self) -> ActivityMonitor
fn clone(&self) -> ActivityMonitor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ActivityMonitor
impl Debug for ActivityMonitor
Source§impl Default for ActivityMonitor
impl Default for ActivityMonitor
Source§impl<'de> Deserialize<'de> for ActivityMonitor
impl<'de> Deserialize<'de> for ActivityMonitor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ActivityMonitor
impl RefUnwindSafe for ActivityMonitor
impl Send for ActivityMonitor
impl Sync for ActivityMonitor
impl Unpin for ActivityMonitor
impl UnsafeUnpin for ActivityMonitor
impl UnwindSafe for ActivityMonitor
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<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