pub struct TimeEvaluator { /* private fields */ }Expand description
Evaluates whether the current bloop’s timestamp falls within a specified time window.
The TimeEvaluator checks if the recorded_at time of a bloop, converted
to a configured timezone, matches the given hour and/or minute, allowing for
an optional leeway duration.
§Behavior
- If
hourisSome, it checks if the time’s hour equals. - If
minuteisSome, it checks if the time’s minute equals. - If either
hourorminuteisNone, that component is ignored (i.e., any hour or minute matches). - The time window starts at the exact configured hour/minute (or current
hour/minute if
None), and extends forward by theleewayduration. - Handles daylight saving time ambiguities by selecting the earliest matching local time.
- If the configured time does not exist on the day (e.g., during a DST gap), evaluation returns false.
Implementations§
Source§impl TimeEvaluator
impl TimeEvaluator
Sourcepub fn new(
hour: Option<u32>,
minute: Option<u32>,
timezone: Tz,
leeway: Option<Duration>,
) -> Result<Self, Error>
pub fn new( hour: Option<u32>, minute: Option<u32>, timezone: Tz, leeway: Option<Duration>, ) -> Result<Self, Error>
Creates a new TimeEvaluator.
§Examples
use std::time::Duration;
use bloop_server_framework::evaluator::time::TimeEvaluator;
let evaluator = TimeEvaluator::new(
Some(12),
None,
chrono_tz::Europe::Berlin,
Some(Duration::from_secs(60))
).unwrap();Trait Implementations§
Source§impl Debug for TimeEvaluator
impl Debug for TimeEvaluator
Source§impl<Player, Metadata, Trigger> Evaluator<Player, Metadata, Trigger> for TimeEvaluator
impl<Player, Metadata, Trigger> Evaluator<Player, Metadata, Trigger> for TimeEvaluator
Source§fn evaluate(
&self,
ctx: &AchievementContext<'_, Player, Metadata, Trigger>,
) -> impl Into<EvalResult>
fn evaluate( &self, ctx: &AchievementContext<'_, Player, Metadata, Trigger>, ) -> impl Into<EvalResult>
Evaluate the achievement for the given context.
Auto Trait Implementations§
impl Freeze for TimeEvaluator
impl RefUnwindSafe for TimeEvaluator
impl Send for TimeEvaluator
impl Sync for TimeEvaluator
impl Unpin for TimeEvaluator
impl UnsafeUnpin for TimeEvaluator
impl UnwindSafe for TimeEvaluator
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
Mutably borrows from an owned value. Read more
Source§impl<T> Erasable for T
impl<T> Erasable for T
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>
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 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>
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