pub struct NumericDate(/* private fields */);
Expand description
Represents NumericDate (see https://datatracker.ietf.org/doc/html/rfc7519#section-2) where the range is restricted to those in which microseconds can be exactly represented, which is approximately between the years 1685 and 2255, which was considered to be sufficient for the purposes of this crate. Note that leap seconds are ignored by this type, just as they’re ignored by NumericDate in the JWT standard.
An f64 value has 52 explicit mantissa bits, meaning that the biggest contiguous range of integer values is from -2^53 to 2^53 (52 zeros after the mantissa’s implicit 1). Using this value to represent exact microseconds gives a maximum range of +-2^53 / (1000000 * 60 * 60 * 24 * 365.25) ~= +-285, which is centered around the Unix epoch start date Jan 1, 1970, 00:00:00 UTC, giving the years 1685 to 2255.
Implementations§
Source§impl NumericDate
impl NumericDate
Sourcepub const MIN: NumericDate
pub const MIN: NumericDate
This is -2^53 / 1_000_000, which is the smallest NumericDate that faithfully represents full microsecond precision.
Sourcepub const MAX: NumericDate
pub const MAX: NumericDate
This is 2^53 / 1_000_000, which is the largest NumericDate that faithfully represents full microsecond precision.
Sourcepub fn as_seconds(self) -> f64
pub fn as_seconds(self) -> f64
Return the f64-valued number of seconds represented by this NumericDate.
Sourcepub fn try_from_seconds(
seconds: f64,
) -> Result<Self, NumericDateConversionError>
pub fn try_from_seconds( seconds: f64, ) -> Result<Self, NumericDateConversionError>
Try to create NumericDate from a f64 value, returning error upon out-of-range.
Trait Implementations§
Source§impl Add<TimeDelta> for NumericDate
Note that this will panic if the addition goes out-of-range.
impl Add<TimeDelta> for NumericDate
Note that this will panic if the addition goes out-of-range.
Source§impl Clone for NumericDate
impl Clone for NumericDate
Source§fn clone(&self) -> NumericDate
fn clone(&self) -> NumericDate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for NumericDate
impl Debug for NumericDate
Source§impl<'de> Deserialize<'de> for NumericDate
impl<'de> Deserialize<'de> for NumericDate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<NumericDate> for DateTime<Utc>
impl From<NumericDate> for DateTime<Utc>
Source§fn from(nd: NumericDate) -> Self
fn from(nd: NumericDate) -> Self
Source§impl From<NumericDate> for LocalResult<DateTime<Utc>>
impl From<NumericDate> for LocalResult<DateTime<Utc>>
Source§fn from(nd: NumericDate) -> Self
fn from(nd: NumericDate) -> Self
Source§impl From<i32> for NumericDate
impl From<i32> for NumericDate
Source§impl FromStr for NumericDate
impl FromStr for NumericDate
Source§impl Hash for NumericDate
impl Hash for NumericDate
Source§impl Ord for NumericDate
impl Ord for NumericDate
Source§fn cmp(&self, other: &NumericDate) -> Ordering
fn cmp(&self, other: &NumericDate) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NumericDate
impl PartialEq for NumericDate
Source§impl PartialOrd for NumericDate
impl PartialOrd for NumericDate
Source§impl Serialize for NumericDate
impl Serialize for NumericDate
Source§impl Sub<TimeDelta> for NumericDate
Note that this will panic if the addition goes out-of-range.
impl Sub<TimeDelta> for NumericDate
Note that this will panic if the addition goes out-of-range.
Source§impl Sub for NumericDate
Note that this will panic if the addition goes out-of-range.
impl Sub for NumericDate
Note that this will panic if the addition goes out-of-range.
Source§impl TryFrom<DateTime<FixedOffset>> for NumericDate
impl TryFrom<DateTime<FixedOffset>> for NumericDate
Source§impl TryFrom<f64> for NumericDate
impl TryFrom<f64> for NumericDate
Source§impl TryFrom<i64> for NumericDate
impl TryFrom<i64> for NumericDate
impl Copy for NumericDate
impl Eq for NumericDate
impl StructuralPartialEq for NumericDate
Auto Trait Implementations§
impl Freeze for NumericDate
impl RefUnwindSafe for NumericDate
impl Send for NumericDate
impl Sync for NumericDate
impl Unpin for NumericDate
impl UnwindSafe for NumericDate
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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<'de, T, C> DeserializeTyped<'de, C> for Twhere
T: Deserialize<'de>,
impl<'de, T, C> DeserializeTyped<'de, C> for Twhere
T: Deserialize<'de>,
fn deserialize_typed<S>(
_: &C,
deserializer: S,
) -> Result<T, <S as Deserializer<'de>>::Error>where
S: Deserializer<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T
.