pub struct Timestamp(/* private fields */);Available on crate features
model-mysql or model-postgres or model-sqlite only.Expand description
A UTC instant, microseconds since the Unix epoch.
use rust_web_server::model::Timestamp;
let t = Timestamp::parse("2026-11-04 12:34:56.5+00:00").unwrap();
assert_eq!(t.to_string(), "2026-11-04T12:34:56.500000Z");
assert_eq!(t, Timestamp::from_unix_micros(1_793_795_696_500_000));Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const fn from_unix_micros(micros: i64) -> Timestamp
pub const fn from_unix_micros(micros: i64) -> Timestamp
The instant micros microseconds after the Unix epoch.
Sourcepub const fn from_unix_seconds(seconds: i64) -> Timestamp
pub const fn from_unix_seconds(seconds: i64) -> Timestamp
The instant seconds seconds after the Unix epoch.
Sourcepub const fn unix_micros(self) -> i64
pub const fn unix_micros(self) -> i64
Microseconds since the Unix epoch.
Sourcepub const fn unix_seconds(self) -> i64
pub const fn unix_seconds(self) -> i64
Whole seconds since the Unix epoch (rounded down).
Sourcepub fn parse(text: &str) -> Result<Timestamp, DbError>
pub fn parse(text: &str) -> Result<Timestamp, DbError>
Parse YYYY-MM-DD, optionally followed by T or a space,
HH:MM[:SS[.fraction]] and a zone (Z, ±HH, ±HHMM, ±HH:MM; none
means UTC). Digits past the sixth of the fraction are dropped.
Sourcepub fn to_rfc3339(self) -> String
pub fn to_rfc3339(self) -> String
RFC 3339 in UTC with six fraction digits:
2026-11-04T12:34:56.123456Z (also what Display writes).
Trait Implementations§
impl Copy for Timestamp
Source§impl<'de> Deserialize<'de> for Timestamp
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Timestamp
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Timestamp
Source§impl FromColumn for Timestamp
impl FromColumn for Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Timestamp
impl PartialOrd 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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more