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
Available on crate feature std
only.
pub fn to_system_time(&self) -> SystemTime
std
only.Convert to SystemTime
.
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for Time
impl<'arbitrary> Arbitrary<'arbitrary> for Time
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self
from the entirety of the given
unstructured data. Read moresource§impl EncodeValue for Time
impl EncodeValue for Time
source§impl From<&Time> for SystemTime
Available on crate feature std
only.
impl From<&Time> for SystemTime
Available on crate feature
std
only.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
Available on crate feature std
only.
impl From<Time> for SystemTime
Available on crate feature
std
only.source§fn from(time: Time) -> SystemTime
fn from(time: Time) -> SystemTime
Converts to this type from the input type.
source§impl PartialEq for Time
impl PartialEq for Time
source§impl TryFrom<SystemTime> for Time
Available on crate feature std
only.
impl TryFrom<SystemTime> for Time
Available on crate feature
std
only.impl Copy for Time
impl Eq for Time
impl StructuralEq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
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> 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.