pub enum Time {
UtcTime(UtcTime),
GeneralTime(GeneralizedTime),
}
Expand description
X.501 Time
as defined in RFC 5280 Section 4.1.2.5.
Schema definition from RFC 5280 Appendix A:
Time ::= CHOICE {
utcTime UTCTime,
generalTime GeneralizedTime
}
Variants§
UtcTime(UtcTime)
Legacy UTC time (has 2-digit year, valid from 1970 to 2049).
Note: RFC 5280 specifies 1950-2049, however due to common operations working on
UNIX_EPOCH
this implementation’s lower bound is 1970.
GeneralTime(GeneralizedTime)
Modern GeneralizedTime
encoding with 4-digit year.
Implementations§
source§impl Time
impl Time
sourcepub fn to_unix_duration(self) -> Duration
pub fn to_unix_duration(self) -> Duration
Get duration since UNIX_EPOCH
.
sourcepub fn to_date_time(&self) -> DateTime
pub fn to_date_time(&self) -> DateTime
Get Time as DateTime
sourcepub fn to_system_time(&self) -> SystemTime
pub fn to_system_time(&self) -> SystemTime
Convert to SystemTime
.
Trait Implementations§
source§impl EncodeValue for Time
impl EncodeValue for Time
source§impl From<&Time> for SystemTime
impl From<&Time> for SystemTime
source§fn from(time: &Time) -> SystemTime
fn from(time: &Time) -> SystemTime
Converts to this type from the input type.
source§impl From<GeneralizedTime> for Time
impl From<GeneralizedTime> for Time
source§fn from(time: GeneralizedTime) -> Time
fn from(time: GeneralizedTime) -> Time
Converts to this type from the input type.
source§impl From<Time> for SystemTime
impl From<Time> for SystemTime
source§fn from(time: Time) -> SystemTime
fn from(time: Time) -> SystemTime
Converts to this type from the input type.
source§impl TryFrom<SystemTime> for Time
impl TryFrom<SystemTime> for Time
impl Copy for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Encode for Twhere
T: EncodeValue + Tagged,
impl<T> Encode for Twhere
T: EncodeValue + Tagged,
source§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this value in bytes when encoded as ASN.1 DER.
source§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided Writer
.
source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
Encode this value to the provided byte slice, returning a sub-slice
containing the encoded message.