pub struct TemporalPermission { /* private fields */ }Expand description
Time-based permission that includes temporal constraints.
Implementations§
Source§impl TemporalPermission
impl TemporalPermission
Sourcepub fn new(permission: Permission) -> Self
pub fn new(permission: Permission) -> Self
Create a new temporal permission.
Sourcepub fn valid_from(self, from: DateTime<Utc>) -> Self
pub fn valid_from(self, from: DateTime<Utc>) -> Self
Set the valid from time.
Sourcepub fn valid_until(self, until: DateTime<Utc>) -> Self
pub fn valid_until(self, until: DateTime<Utc>) -> Self
Set the valid until time.
Sourcepub fn with_schedule(self, schedule: Schedule) -> Self
pub fn with_schedule(self, schedule: Schedule) -> Self
Set a recurring schedule.
Sourcepub fn with_max_usage(self, max_usage: u32) -> Self
pub fn with_max_usage(self, max_usage: u32) -> Self
Set maximum usage count.
Sourcepub fn is_valid_at(&self, time: DateTime<Utc>) -> bool
pub fn is_valid_at(&self, time: DateTime<Utc>) -> bool
Check if the permission is valid at the given time.
Sourcepub fn is_currently_valid(&self) -> bool
pub fn is_currently_valid(&self) -> bool
Check if the permission is currently valid.
Sourcepub fn record_usage(&mut self) -> Result<()>
pub fn record_usage(&mut self) -> Result<()>
Record usage of this permission.
Sourcepub fn permission(&self) -> &Permission
pub fn permission(&self) -> &Permission
Get the underlying permission.
Sourcepub fn usage_stats(&self) -> (u32, Option<u32>)
pub fn usage_stats(&self) -> (u32, Option<u32>)
Get usage statistics.
Sourcepub fn time_until_valid(&self) -> Option<Duration>
pub fn time_until_valid(&self) -> Option<Duration>
Get time until this permission becomes valid (if not yet valid).
Sourcepub fn time_until_expiry(&self) -> Option<Duration>
pub fn time_until_expiry(&self) -> Option<Duration>
Get time until this permission expires.
Trait Implementations§
Source§impl Clone for TemporalPermission
impl Clone for TemporalPermission
Source§fn clone(&self) -> TemporalPermission
fn clone(&self) -> TemporalPermission
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 moreAuto Trait Implementations§
impl Freeze for TemporalPermission
impl !RefUnwindSafe for TemporalPermission
impl Send for TemporalPermission
impl Sync for TemporalPermission
impl Unpin for TemporalPermission
impl !UnwindSafe for TemporalPermission
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