pub struct TimeWindow {
pub start: Option<NaiveTime>,
pub end: Option<NaiveTime>,
pub days: Vec<u32>,
}Expand description
Time window specification for rule matching.
Defines a time range during which a rule is active. Times are evaluated in UTC.
Fields§
§start: Option<NaiveTime>Start time (inclusive). None means from midnight.
end: Option<NaiveTime>End time (inclusive). None means until midnight.
days: Vec<u32>Days of the week when this window is active (0 = Monday, 6 = Sunday). Empty means all days.
Implementations§
Source§impl TimeWindow
impl TimeWindow
Sourcepub fn hours(start_hour: u32, end_hour: u32) -> Self
pub fn hours(start_hour: u32, end_hour: u32) -> Self
Create a time window for specific hours (24-hour format, UTC).
§Example
use axum_acl::TimeWindow;
// Active from 9 AM to 5 PM UTC
let window = TimeWindow::hours(9, 17);Sourcepub fn hours_on_days(start_hour: u32, end_hour: u32, days: Vec<u32>) -> Self
pub fn hours_on_days(start_hour: u32, end_hour: u32, days: Vec<u32>) -> Self
Create a time window for specific hours on specific days.
§Arguments
start_hour- Start hour (0-23)end_hour- End hour (0-23)days- Days of week (0 = Monday, 6 = Sunday)
§Example
use axum_acl::TimeWindow;
// Active Mon-Fri 9 AM to 5 PM UTC
let window = TimeWindow::hours_on_days(9, 17, vec![0, 1, 2, 3, 4]);Sourcepub fn matches_now(&self) -> bool
pub fn matches_now(&self) -> bool
Check if the current time falls within this window.
Trait Implementations§
Source§impl Clone for TimeWindow
impl Clone for TimeWindow
Source§fn clone(&self) -> TimeWindow
fn clone(&self) -> TimeWindow
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TimeWindow
impl Debug for TimeWindow
Source§impl Default for TimeWindow
impl Default for TimeWindow
Source§fn default() -> TimeWindow
fn default() -> TimeWindow
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TimeWindow
impl RefUnwindSafe for TimeWindow
impl Send for TimeWindow
impl Sync for TimeWindow
impl Unpin for TimeWindow
impl UnwindSafe for TimeWindow
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