pub struct UtcTime(/* private fields */);
Available on crate feature
pkcs8
only.Expand description
ASN.1 UTCTime
type.
This type implements the validity requirements specified in RFC 5280 Section 4.1.2.5.1, namely:
For the purposes of this profile, UTCTime values MUST be expressed in Greenwich Mean Time (Zulu) and MUST include seconds (i.e., times are
YYMMDDHHMMSSZ
), even where the number of seconds is zero. Conforming systems MUST interpret the year field (YY
) as follows:
- Where
YY
is greater than or equal to 50, the year SHALL be interpreted as19YY
; and- Where
YY
is less than 50, the year SHALL be interpreted as20YY
.
Note: Due to common operations working on UNIX_EPOCH
UtcTime
s are
only supported for the years 1970-2049.
Implementations§
§impl UtcTime
impl UtcTime
pub fn from_date_time(datetime: DateTime) -> Result<UtcTime, Error>
pub fn from_date_time(datetime: DateTime) -> Result<UtcTime, Error>
pub fn to_date_time(&self) -> DateTime
pub fn to_date_time(&self) -> DateTime
pub fn from_unix_duration(unix_duration: Duration) -> Result<UtcTime, Error>
pub fn from_unix_duration(unix_duration: Duration) -> Result<UtcTime, Error>
pub fn to_unix_duration(&self) -> Duration
pub fn to_unix_duration(&self) -> Duration
Get the duration of this timestamp since UNIX_EPOCH
.
pub fn from_system_time(time: SystemTime) -> Result<UtcTime, Error>
Available on crate feature std
only.
pub fn from_system_time(time: SystemTime) -> Result<UtcTime, Error>
std
only.Instantiate from SystemTime
.
pub 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§
§impl<'a> DecodeValue<'a> for UtcTime
impl<'a> DecodeValue<'a> for UtcTime
§impl EncodeValue for UtcTime
impl EncodeValue for UtcTime
§impl Ord for UtcTime
impl Ord for UtcTime
§impl PartialOrd for UtcTime
impl PartialOrd for UtcTime
§fn partial_cmp(&self, other: &UtcTime) -> Option<Ordering>
fn partial_cmp(&self, other: &UtcTime) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for UtcTime
impl Eq for UtcTime
impl StructuralPartialEq for UtcTime
Auto Trait Implementations§
impl RefUnwindSafe for UtcTime
impl Send for UtcTime
impl Sync for UtcTime
impl Unpin for UtcTime
impl UnwindSafe for UtcTime
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
§impl<'a, T> Choice<'a> for T
impl<'a, T> Choice<'a> for T
§fn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Is the provided
Tag
decodable as a variant of this CHOICE
?§impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
impl<'a, T> Decode<'a> for Twhere
T: DecodeValue<'a> + FixedTag,
§impl<T> Encode for Twhere
T: EncodeValue + Tagged,
impl<T> Encode for Twhere
T: EncodeValue + Tagged,
§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.
§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
.
§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.