pub struct GeneralizedTime(/* private fields */);Expand description
ASN.1 GeneralizedTime type.
This type implements the validity requirements specified in RFC 5280 Section 4.1.2.5.2, namely:
For the purposes of this profile, GeneralizedTime values MUST be expressed in Greenwich Mean Time (Zulu) and MUST include seconds (i.e., times are
YYYYMMDDHHMMSSZ), even where the number of seconds is zero. GeneralizedTime values MUST NOT include fractional seconds.
Implementations§
Source§impl GeneralizedTime
impl GeneralizedTime
Sourcepub const fn from_date_time(datetime: DateTime) -> Self
pub const fn from_date_time(datetime: DateTime) -> Self
Create a GeneralizedTime from a DateTime.
Sourcepub const fn to_date_time(&self) -> DateTime
pub const fn to_date_time(&self) -> DateTime
Convert this GeneralizedTime into a DateTime.
Sourcepub fn from_unix_duration(unix_duration: Duration) -> Result<Self>
pub fn from_unix_duration(unix_duration: Duration) -> Result<Self>
Create a new GeneralizedTime given a Duration since UNIX_EPOCH
(a.k.a. “Unix time”).
§Errors
Returns Error with a value error kind in the event unix_duration could not be parsed.
Sourcepub fn to_unix_duration(&self) -> Duration
pub fn to_unix_duration(&self) -> Duration
Get the duration of this timestamp since UNIX_EPOCH.
Sourcepub fn from_system_time(time: SystemTime) -> Result<Self>
pub fn from_system_time(time: SystemTime) -> Result<Self>
Sourcepub fn to_system_time(&self) -> SystemTime
pub fn to_system_time(&self) -> SystemTime
Convert to SystemTime.
Trait Implementations§
Source§impl Clone for GeneralizedTime
impl Clone for GeneralizedTime
Source§fn clone(&self) -> GeneralizedTime
fn clone(&self) -> GeneralizedTime
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 GeneralizedTime
impl Debug for GeneralizedTime
Source§impl<'a> DecodeValue<'a> for GeneralizedTime
impl<'a> DecodeValue<'a> for GeneralizedTime
Source§impl EncodeValue for GeneralizedTime
impl EncodeValue for GeneralizedTime
Source§impl From<&DateTime> for GeneralizedTime
impl From<&DateTime> for GeneralizedTime
Source§impl From<&GeneralizedTime> for DateTime
impl From<&GeneralizedTime> for DateTime
Source§fn from(utc_time: &GeneralizedTime) -> DateTime
fn from(utc_time: &GeneralizedTime) -> DateTime
Converts to this type from the input type.
Source§impl From<&GeneralizedTime> for GeneralizedTime
impl From<&GeneralizedTime> for GeneralizedTime
Source§fn from(value: &GeneralizedTime) -> GeneralizedTime
fn from(value: &GeneralizedTime) -> GeneralizedTime
Converts to this type from the input type.
Source§impl From<&GeneralizedTime> for SystemTime
Available on crate feature std only.
impl From<&GeneralizedTime> for SystemTime
Available on crate feature
std only.Source§fn from(time: &GeneralizedTime) -> SystemTime
fn from(time: &GeneralizedTime) -> SystemTime
Converts to this type from the input type.
Source§impl From<DateTime> for GeneralizedTime
impl From<DateTime> for GeneralizedTime
Source§impl From<GeneralizedTime> for DateTime
impl From<GeneralizedTime> for DateTime
Source§fn from(utc_time: GeneralizedTime) -> DateTime
fn from(utc_time: GeneralizedTime) -> DateTime
Converts to this type from the input type.
Source§impl From<GeneralizedTime> for SystemTime
Available on crate feature std only.
impl From<GeneralizedTime> for SystemTime
Available on crate feature
std only.Source§fn from(time: GeneralizedTime) -> SystemTime
fn from(time: GeneralizedTime) -> SystemTime
Converts to this type from the input type.
Source§impl Ord for GeneralizedTime
impl Ord for GeneralizedTime
Source§fn cmp(&self, other: &GeneralizedTime) -> Ordering
fn cmp(&self, other: &GeneralizedTime) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for GeneralizedTime
impl PartialEq for GeneralizedTime
Source§fn eq(&self, other: &GeneralizedTime) -> bool
fn eq(&self, other: &GeneralizedTime) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for GeneralizedTime
impl PartialOrd for GeneralizedTime
Source§impl<'__der> TryFrom<&'__der Any> for GeneralizedTime
Available on crate feature alloc only.
impl<'__der> TryFrom<&'__der Any> for GeneralizedTime
Available on crate feature
alloc only.Source§impl TryFrom<&SystemTime> for GeneralizedTime
Available on crate feature std only.
impl TryFrom<&SystemTime> for GeneralizedTime
Available on crate feature
std only.Source§fn try_from(time: &SystemTime) -> Result<GeneralizedTime>
fn try_from(time: &SystemTime) -> Result<GeneralizedTime>
Performs the conversion.
Source§impl<'__der> TryFrom<AnyRef<'__der>> for GeneralizedTime
impl<'__der> TryFrom<AnyRef<'__der>> for GeneralizedTime
Source§impl TryFrom<SystemTime> for GeneralizedTime
Available on crate feature std only.
impl TryFrom<SystemTime> for GeneralizedTime
Available on crate feature
std only.Source§fn try_from(time: SystemTime) -> Result<GeneralizedTime>
fn try_from(time: SystemTime) -> Result<GeneralizedTime>
Performs the conversion.
impl Copy for GeneralizedTime
impl Eq for GeneralizedTime
impl StructuralPartialEq for GeneralizedTime
Auto Trait Implementations§
impl Freeze for GeneralizedTime
impl RefUnwindSafe for GeneralizedTime
impl Send for GeneralizedTime
impl Sync for GeneralizedTime
impl Unpin for GeneralizedTime
impl UnsafeUnpin for GeneralizedTime
impl UnwindSafe for GeneralizedTime
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<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag + 'a,
impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag + 'a,
Source§type Error = <T as DecodeValue<'a>>::Error
type Error = <T as DecodeValue<'a>>::Error
Type returned in the event of a decoding error.
Source§fn decode<R>(reader: &mut R) -> Result<T, <T as DecodeValue<'a>>::Error>where
R: Reader<'a>,
fn decode<R>(reader: &mut R) -> Result<T, <T as DecodeValue<'a>>::Error>where
R: Reader<'a>,
Attempt to decode this TLV message using the provided decoder. Read more
Source§impl<T> Encode for T
impl<T> Encode for T
Source§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this TLV object in bytes when encoded as ASN.1 DER. Read more
Source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Encode this TLV object to the provided byte slice, returning a sub-slice
containing the encoded message. Read more
Source§impl<T> IsConstructed for T
impl<T> IsConstructed for T
Source§const CONSTRUCTED: bool = const CONSTRUCTED: bool = T::TAG.is_constructed();
const CONSTRUCTED: bool = const CONSTRUCTED: bool = T::TAG.is_constructed();
ASN.1 constructed bit