pub trait Pattern: Sealed + Clone {
// Required methods
fn next_after(
&self,
instant: DateTime,
range: DateTimeRange,
) -> Option<DateTime>;
fn previous_before(
&self,
instant: DateTime,
range: DateTimeRange,
) -> Option<DateTime>;
fn closest_to(
&self,
instant: DateTime,
range: DateTimeRange,
) -> Option<DateTime>;
}Expand description
A trait for recurrence patterns.
Values implementing Pattern are passed to Series::new or Series::try_new
to build a new series of recurring events.
Since values implementing this trait must uphold some invariants to ensure correctness it is sealed to prevent implementing it outside of this crate.
There is usually no need to interact with this trait directly. Use the functionality provided
by Series instead because it is more convenient.
The pattern module contains implementations of various recurrence patterns.
Required Methods§
Sourcefn next_after(
&self,
instant: DateTime,
range: DateTimeRange,
) -> Option<DateTime>
fn next_after( &self, instant: DateTime, range: DateTimeRange, ) -> Option<DateTime>
Find the next DateTime after instant within a range.
This must always returns a datetime that is strictly larger than instant or None if
the next event would be greater or equal to the range’s end. If instant happens before
the range’s start, this must return the first event within the range.
Sourcefn previous_before(
&self,
instant: DateTime,
range: DateTimeRange,
) -> Option<DateTime>
fn previous_before( &self, instant: DateTime, range: DateTimeRange, ) -> Option<DateTime>
Find the previous DateTime before instant within a range.
This must always returns a datetime that is strictly smaller than instant or None if
the previous event would be less than the range’s start. If instant happens after
the range’s end, this must return the last event within the range.
Sourcefn closest_to(
&self,
instant: DateTime,
range: DateTimeRange,
) -> Option<DateTime>
fn closest_to( &self, instant: DateTime, range: DateTimeRange, ) -> Option<DateTime>
Find a DateTime closest to instant within a range.
The returned datetime may happen before, after and exactly at instant. This must only
return None if there is no event within the range.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.