pub struct TimeSlots(/* private fields */);
Expand description
TimeSlots represents a collection of time intervals where each interval is defined by a start and end time.
Implementations§
Source§impl TimeSlots
impl TimeSlots
Sourcepub fn values(&self) -> &Vec<TimeSlot>
pub fn values(&self) -> &Vec<TimeSlot>
Get time slots vector
§Example
use api_tools::server::axum::layers::time_limiter::TimeSlots;
let time_slots: TimeSlots = "08:00-12:00,13:00-17:00".into();
assert_eq!(time_slots.values().len(), 2);
assert_eq!(time_slots.values()[0].start, "08:00");
assert_eq!(time_slots.values()[0].end, "12:00");
assert_eq!(time_slots.values()[1].start, "13:00");
assert_eq!(time_slots.values()[1].end, "17:00");
Sourcepub fn contains(&self, time: &str) -> bool
pub fn contains(&self, time: &str) -> bool
Check if a time is in the time slots list
§Example
use api_tools::server::axum::layers::time_limiter::TimeSlots;
let time_slots: TimeSlots = "08:00-12:00,13:00-17:00".into();
let now = "09:00";
assert_eq!(time_slots.contains(now), true);
let now = "08:00";
assert_eq!(time_slots.contains(now), true);
let now = "17:00";
assert_eq!(time_slots.contains(now), true);
let now = "12:30";
assert_eq!(time_slots.contains(now), false);
let time_slots: TimeSlots = "".into();
let now = "09:00";
assert_eq!(time_slots.contains(now), false);
Trait Implementations§
impl StructuralPartialEq for TimeSlots
Auto Trait Implementations§
impl Freeze for TimeSlots
impl RefUnwindSafe for TimeSlots
impl Send for TimeSlots
impl Sync for TimeSlots
impl Unpin for TimeSlots
impl UnwindSafe for TimeSlots
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> 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> Pointable for T
impl<T> Pointable for T
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Add request id header and extension. Read more
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Add request id header and extension, using
x-request-id
as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Propgate request ids from requests to responses. Read more
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
Propgate request ids from requests to responses, using
x-request-id
as the header name. Read more