Struct identity_core::common::Timestamp
source · pub struct Timestamp(/* private fields */);Expand description
A parsed Timestamp.
Implementations§
source§impl Timestamp
impl Timestamp
sourcepub fn parse(input: &str) -> Result<Self>
pub fn parse(input: &str) -> Result<Self>
Parses a Timestamp from the provided input string, normalized to UTC+00:00 with fractional
seconds truncated.
See the datetime DID-core specification.
sourcepub fn now_utc() -> Self
pub fn now_utc() -> Self
Creates a new Timestamp with the current date and time, normalized to UTC+00:00 with
fractional seconds truncated.
See the datetime DID-core specification.
sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Returns the Timestamp as an RFC 3339 String.
sourcepub fn from_unix(seconds: i64) -> Result<Self>
pub fn from_unix(seconds: i64) -> Result<Self>
Creates a new Timestamp from the given Unix timestamp.
The timestamp must be in the valid range for RFC 3339.
§Errors
Error::InvalidTimestamp if seconds is outside of the interval [-62167219200,253402300799].
sourcepub fn checked_add(self, duration: Duration) -> Option<Self>
pub fn checked_add(self, duration: Duration) -> Option<Self>
Computes self + duration
Returns None if the operation leads to a timestamp not in the valid range for RFC 3339.
sourcepub fn checked_sub(self, duration: Duration) -> Option<Self>
pub fn checked_sub(self, duration: Duration) -> Option<Self>
Computes self - duration
Returns None if the operation leads to a timestamp not in the valid range for RFC 3339.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
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 Ord for Timestamp
impl Ord for Timestamp
source§impl PartialEq for Timestamp
impl PartialEq for Timestamp
source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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> FromJson for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromJson for Twhere
T: for<'de> Deserialize<'de>,
source§fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self>
fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self>
Self from a string of JSON text.source§fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self>
fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self>
Self from bytes of JSON text.source§fn from_json_value(json: Value) -> Result<Self>
fn from_json_value(json: Value) -> Result<Self>
Self from a serde_json::Value.source§impl<T> ToJson for Twhere
T: Serialize,
impl<T> ToJson for Twhere
T: Serialize,
source§fn to_json_value(&self) -> Result<Value>
fn to_json_value(&self) -> Result<Value>
self as a serde_json::Value.source§fn to_json_pretty(&self) -> Result<String>
fn to_json_pretty(&self) -> Result<String>
self as a pretty-printed string of JSON.