Skip to main content

Timestamp

Struct Timestamp 

Source
pub struct Timestamp(/* private fields */);
Expand description

A Unix timestamp

Implementations§

Source§

impl Timestamp

Source

pub const MIN: Self

Source

pub const UNIX_EPOCH: Self

Source

pub const MAX: Self

Source

pub fn now() -> Self

Source

pub const fn from_nanos(nanos: i128) -> Option<Self>

Source

pub const fn from_micros(micros: i128) -> Option<Self>

Source

pub const fn from_millis(millis: i64) -> Option<Self>

Source

pub const fn from_secs(secs: i64) -> Option<Self>

Source

pub fn checked_add_unsigned(self, rhs: Duration) -> Option<Self>

Source

pub fn checked_sub_unsigned(self, rhs: Duration) -> Option<Self>

Source

pub fn saturating_add_unsigned(self, rhs: Duration) -> Self

Source

pub fn saturating_sub_unsigned(self, rhs: Duration) -> Self

Source

pub fn duration_since(&self, other: Self) -> Result<Duration, Duration>

Source

pub const fn truncate_subsecs(self) -> Self

Source

pub const fn as_nanos(&self) -> i128

Source

pub const fn as_micros(&self) -> i128

Source

pub const fn as_millis(&self) -> i64

Source

pub const fn as_secs(&self) -> i64

Trait Implementations§

Source§

impl Add<Duration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Duration> for Timestamp

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl<'a> Arbitrary<'a> for Timestamp

Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<'a, const FROM: i128, const TO: i128> ArbitraryAs<'a, Timestamp> for RangeNanos<FROM, TO>

Source§

fn arbitrary_as(u: &mut Unstructured<'a>) -> Result<Timestamp>

§

fn arbitrary_take_rest_as(u: Unstructured<'a>) -> Result<T, Error>

§

fn size_hint_as(depth: usize) -> (usize, Option<usize>)

§

fn try_size_hint_as( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Source§

impl<I> BorshDeserializeAs<Timestamp> for TimestampMicroSeconds<I>
where I: TryInto<i128> + BorshDeserialize, I::Error: Display,

Source§

fn deserialize_as<R>(reader: &mut R) -> Result<Timestamp>
where R: Read,

Source§

impl<I> BorshDeserializeAs<Timestamp> for TimestampMilliSeconds<I>
where I: TryInto<i64> + BorshDeserialize, I::Error: Display,

Source§

fn deserialize_as<R>(reader: &mut R) -> Result<Timestamp>
where R: Read,

Source§

impl<I> BorshDeserializeAs<Timestamp> for TimestampNanoSeconds<I>
where I: TryInto<i128> + BorshDeserialize, I::Error: Display,

Source§

fn deserialize_as<R>(reader: &mut R) -> Result<Timestamp>
where R: Read,

Source§

impl<I> BorshDeserializeAs<Timestamp> for TimestampSeconds<I>
where I: TryInto<i64> + BorshDeserialize, I::Error: Display,

Source§

fn deserialize_as<R>(reader: &mut R) -> Result<Timestamp>
where R: Read,

Source§

impl<I> BorshSchemaAs<Timestamp> for TimestampMicroSeconds<I>
where I: BorshSchema,

Source§

fn declaration_as() -> Declaration

Source§

fn add_definitions_recursively_as( definitions: &mut BTreeMap<Declaration, Definition>, )

Source§

impl<I> BorshSchemaAs<Timestamp> for TimestampMilliSeconds<I>
where I: BorshSchema,

Source§

fn declaration_as() -> Declaration

Source§

fn add_definitions_recursively_as( definitions: &mut BTreeMap<Declaration, Definition>, )

Source§

impl<I> BorshSchemaAs<Timestamp> for TimestampNanoSeconds<I>
where I: BorshSchema,

Source§

fn declaration_as() -> Declaration

Source§

fn add_definitions_recursively_as( definitions: &mut BTreeMap<Declaration, Definition>, )

Source§

impl<I> BorshSchemaAs<Timestamp> for TimestampSeconds<I>
where I: BorshSchema,

Source§

fn declaration_as() -> Declaration

Source§

fn add_definitions_recursively_as( definitions: &mut BTreeMap<Declaration, Definition>, )

Source§

impl<I> BorshSerializeAs<Timestamp> for TimestampMicroSeconds<I>
where I: TryFrom<i128> + BorshSerialize, I::Error: Display,

Source§

fn serialize_as<W>(source: &Timestamp, writer: &mut W) -> Result<()>
where W: Write,

Source§

impl<I> BorshSerializeAs<Timestamp> for TimestampMilliSeconds<I>
where I: TryFrom<i64> + BorshSerialize, I::Error: Display,

Source§

fn serialize_as<W>(source: &Timestamp, writer: &mut W) -> Result<()>
where W: Write,

Source§

impl<I> BorshSerializeAs<Timestamp> for TimestampNanoSeconds<I>
where I: TryFrom<i128> + BorshSerialize, I::Error: Display,

Source§

fn serialize_as<W>(source: &Timestamp, writer: &mut W) -> Result<()>
where W: Write,

Source§

impl<I> BorshSerializeAs<Timestamp> for TimestampSeconds<I>
where I: TryFrom<i64> + BorshSerialize, I::Error: Display,

Source§

fn serialize_as<W>(source: &Timestamp, writer: &mut W) -> Result<()>
where W: Write,

Source§

impl Clone for Timestamp

Source§

fn clone(&self) -> Timestamp

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Timestamp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Timestamp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Timestamp
where Self: FromStr, <Self as FromStr>::Err: Display,

Source§

fn deserialize<__D>(deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de, F> DeserializeAs<'de, Timestamp> for TimestampMicroSeconds<F>
where F: DeserializeAs<'de, i128> + ?Sized,

Source§

fn deserialize_as<D>(deserializer: D) -> Result<Timestamp, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer.
Source§

impl<'de, F> DeserializeAs<'de, Timestamp> for TimestampMilliSeconds<F>
where F: DeserializeAs<'de, i64> + ?Sized,

Source§

fn deserialize_as<D>(deserializer: D) -> Result<Timestamp, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer.
Source§

impl<'de, F> DeserializeAs<'de, Timestamp> for TimestampNanoSeconds<F>
where F: DeserializeAs<'de, i128> + ?Sized,

Source§

fn deserialize_as<D>(deserializer: D) -> Result<Timestamp, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer.
Source§

impl<'de, F> DeserializeAs<'de, Timestamp> for TimestampSeconds<F>
where F: DeserializeAs<'de, i64> + ?Sized,

Source§

fn deserialize_as<D>(deserializer: D) -> Result<Timestamp, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer.
Source§

impl Display for Timestamp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Timestamp

Source§

type Err = Parse

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Timestamp

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for Timestamp

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl<F> JsonSchemaAs<Timestamp> for TimestampMicroSeconds<F>
where F: JsonSchemaAs<i128> + ?Sized,

Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl<F> JsonSchemaAs<Timestamp> for TimestampMilliSeconds<F>
where F: JsonSchemaAs<i64> + ?Sized,

Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl<F> JsonSchemaAs<Timestamp> for TimestampNanoSeconds<F>
where F: JsonSchemaAs<i128> + ?Sized,

Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl<F> JsonSchemaAs<Timestamp> for TimestampSeconds<F>
where F: JsonSchemaAs<i64> + ?Sized,

Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl Ord for Timestamp

Source§

fn cmp(&self, other: &Timestamp) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Timestamp

Source§

fn eq(&self, other: &Timestamp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Timestamp

Source§

fn partial_cmp(&self, other: &Timestamp) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Timestamp
where Self: Display,

Source§

fn serialize<__S>(&self, serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<F> SerializeAs<Timestamp> for TimestampMicroSeconds<F>
where F: SerializeAs<i128> + ?Sized,

Source§

fn serialize_as<S>(source: &Timestamp, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer.
Source§

impl<F> SerializeAs<Timestamp> for TimestampMilliSeconds<F>
where F: SerializeAs<i64> + ?Sized,

Source§

fn serialize_as<S>(source: &Timestamp, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer.
Source§

impl<F> SerializeAs<Timestamp> for TimestampNanoSeconds<F>
where F: SerializeAs<i128> + ?Sized,

Source§

fn serialize_as<S>(source: &Timestamp, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer.
Source§

impl<F> SerializeAs<Timestamp> for TimestampSeconds<F>
where F: SerializeAs<i64> + ?Sized,

Source§

fn serialize_as<S>(source: &Timestamp, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer.
Source§

impl Sub<Duration> for Timestamp

Source§

type Output = Timestamp

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Duration) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Duration> for Timestamp

Source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
Source§

impl Copy for Timestamp

Source§

impl Eq for Timestamp

Source§

impl StructuralPartialEq for Timestamp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,