Struct sequoia_openpgp::packet::signature::subpacket::CLOCK_SKEW_TOLERANCE [−][src]
pub struct CLOCK_SKEW_TOLERANCE { /* fields omitted */ }
The default amount of tolerance to use when comparing some timestamps.
Used by Subpacket::signature_alive
.
When determining whether a timestamp generated on another machine is valid now, we need to account for clock skew. (Note: you don’t normally need to consider clock skew when evaluating a signature’s validity at some time in the past.)
We tolerate half an hour of skew based on the following anecdote: In 2019, a developer using Sequoia in a Windows VM running inside of Virtual Box on Mac OS X reported that he typically observed a few minutes of clock skew and occasionally saw over 20 minutes of clock skew.
Note: when new messages override older messages, and their signatures are evaluated at some arbitrary point in time, an application may not see a consistent state if it uses a tolerance. Consider an application that has two messages and wants to get the current message at time te:
- t0: message 0
- te: “get current message”
- t1: message 1
If te is close to t1, then t1 may be considered valid, which is probably not what you want.
Methods from Deref<Target = Duration>
pub const SECOND: Duration
[src]
pub const MILLISECOND: Duration
[src]
pub const MICROSECOND: Duration
[src]
pub const NANOSECOND: Duration
[src]
pub const ZERO: Duration
1.53.0[src]
pub const MAX: Duration
1.53.0[src]
pub const fn is_zero(&self) -> bool
1.53.0 (const: 1.53.0)[src]
pub const fn is_zero(&self) -> bool
1.53.0 (const: 1.53.0)[src]Returns true if this Duration
spans no time.
Examples
use std::time::Duration; assert!(Duration::ZERO.is_zero()); assert!(Duration::new(0, 0).is_zero()); assert!(Duration::from_nanos(0).is_zero()); assert!(Duration::from_secs(0).is_zero()); assert!(!Duration::new(1, 1).is_zero()); assert!(!Duration::from_nanos(1).is_zero()); assert!(!Duration::from_secs(1).is_zero());
pub const fn as_secs(&self) -> u64
1.3.0 (const: 1.32.0)[src]
pub const fn as_secs(&self) -> u64
1.3.0 (const: 1.32.0)[src]Returns the number of whole seconds contained by this Duration
.
The returned value does not include the fractional (nanosecond) part of the
duration, which can be obtained using subsec_nanos
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_secs(), 5);
To determine the total number of seconds represented by the Duration
,
use as_secs
in combination with subsec_nanos
:
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(5.730023852, duration.as_secs() as f64 + duration.subsec_nanos() as f64 * 1e-9);
pub const fn subsec_millis(&self) -> u32
1.27.0 (const: 1.32.0)[src]
pub const fn subsec_millis(&self) -> u32
1.27.0 (const: 1.32.0)[src]Returns the fractional part of this Duration
, in whole milliseconds.
This method does not return the length of the duration when represented by milliseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one thousand).
Examples
use std::time::Duration; let duration = Duration::from_millis(5432); assert_eq!(duration.as_secs(), 5); assert_eq!(duration.subsec_millis(), 432);
pub const fn subsec_micros(&self) -> u32
1.27.0 (const: 1.32.0)[src]
pub const fn subsec_micros(&self) -> u32
1.27.0 (const: 1.32.0)[src]Returns the fractional part of this Duration
, in whole microseconds.
This method does not return the length of the duration when represented by microseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one million).
Examples
use std::time::Duration; let duration = Duration::from_micros(1_234_567); assert_eq!(duration.as_secs(), 1); assert_eq!(duration.subsec_micros(), 234_567);
pub const fn subsec_nanos(&self) -> u32
1.3.0 (const: 1.32.0)[src]
pub const fn subsec_nanos(&self) -> u32
1.3.0 (const: 1.32.0)[src]Returns the fractional part of this Duration
, in nanoseconds.
This method does not return the length of the duration when represented by nanoseconds. The returned number always represents a fractional portion of a second (i.e., it is less than one billion).
Examples
use std::time::Duration; let duration = Duration::from_millis(5010); assert_eq!(duration.as_secs(), 5); assert_eq!(duration.subsec_nanos(), 10_000_000);
pub const fn as_millis(&self) -> u128
1.33.0 (const: 1.33.0)[src]
pub const fn as_millis(&self) -> u128
1.33.0 (const: 1.33.0)[src]Returns the total number of whole milliseconds contained by this Duration
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_millis(), 5730);
pub const fn as_micros(&self) -> u128
1.33.0 (const: 1.33.0)[src]
pub const fn as_micros(&self) -> u128
1.33.0 (const: 1.33.0)[src]Returns the total number of whole microseconds contained by this Duration
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_micros(), 5730023);
pub const fn as_nanos(&self) -> u128
1.33.0 (const: 1.33.0)[src]
pub const fn as_nanos(&self) -> u128
1.33.0 (const: 1.33.0)[src]Returns the total number of nanoseconds contained by this Duration
.
Examples
use std::time::Duration; let duration = Duration::new(5, 730023852); assert_eq!(duration.as_nanos(), 5730023852);
pub const fn as_secs_f64(&self) -> f64
1.38.0[src]
pub const fn as_secs_f64(&self) -> f64
1.38.0[src]Returns the number of seconds contained by this Duration
as f64
.
The returned value does include the fractional (nanosecond) part of the duration.
Examples
use std::time::Duration; let dur = Duration::new(2, 700_000_000); assert_eq!(dur.as_secs_f64(), 2.7);
pub const fn as_secs_f32(&self) -> f32
1.38.0[src]
pub const fn as_secs_f32(&self) -> f32
1.38.0[src]Returns the number of seconds contained by this Duration
as f32
.
The returned value does include the fractional (nanosecond) part of the duration.
Examples
use std::time::Duration; let dur = Duration::new(2, 700_000_000); assert_eq!(dur.as_secs_f32(), 2.7);
Trait Implementations
impl Deref for CLOCK_SKEW_TOLERANCE
[src]
impl Deref for CLOCK_SKEW_TOLERANCE
[src]impl LazyStatic for CLOCK_SKEW_TOLERANCE
[src]
impl LazyStatic for CLOCK_SKEW_TOLERANCE
[src]fn initialize(lazy: &Self)
[src]
Auto Trait Implementations
impl RefUnwindSafe for CLOCK_SKEW_TOLERANCE
impl Send for CLOCK_SKEW_TOLERANCE
impl Sync for CLOCK_SKEW_TOLERANCE
impl Unpin for CLOCK_SKEW_TOLERANCE
impl UnwindSafe for CLOCK_SKEW_TOLERANCE
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self