pub struct Time { /* private fields */ }
Expand description
Time
Serialized as f64 Deserialized from unsigned integers (seconds), floats, [sec, nsec] seqs
With “db” feature provides sqlx interfaces for Sqlite (stored as nanoseconds integer) and Postgres (stored as TIMESTAMP/TIMESTAMPTZ)
Implementations§
Source§impl Time
impl Time
pub fn try_into_naivedatetime(self) -> EResult<NaiveDateTime>
pub fn try_into_datetime_local(self) -> EResult<DateTime<Local>>
pub fn try_into_datetime_utc(self) -> EResult<DateTime<Utc>>
Source§impl Time
impl Time
pub fn new(sec: u64, nsec: u64) -> Self
Sourcepub fn now() -> Self
pub fn now() -> Self
§Panics
Will panic if the system real-time clock is not available Will panic on Windows if the clock is set before 1.1.1970
Sourcepub fn now_monotonic() -> Self
pub fn now_monotonic() -> Self
On Windows returns time since the first access
§Panics
Will panic if the system monotonic clock is not available
pub fn from_timestamp_ns(timestamp_ns: u64) -> Self
pub fn from_timestamp_us(timestamp_us: u64) -> Self
pub fn from_timestamp_ms(timestamp_ms: u64) -> Self
pub fn from_timestamp(timestamp: f64) -> Self
pub fn timestamp(&self) -> f64
pub fn timestamp_sec(&self) -> u64
pub fn timestamp_ns(&self) -> u64
pub fn timestamp_us(&self) -> u64
pub fn timestamp_ms(&self) -> u64
Trait Implementations§
Source§impl<'r> Decode<'r, Postgres> for Time
impl<'r> Decode<'r, Postgres> for Time
Source§fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError>
fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError>
Decode a new value of this type using a raw value from the database.
Source§impl<'r> Decode<'r, Sqlite> for Time
impl<'r> Decode<'r, Sqlite> for Time
Source§fn decode(value: SqliteValueRef<'r>) -> Result<Self, BoxDynError>
fn decode(value: SqliteValueRef<'r>) -> Result<Self, BoxDynError>
Decode a new value of this type using a raw value from the database.
Source§impl<'de> Deserialize<'de> for Time
impl<'de> Deserialize<'de> for Time
Source§fn deserialize<D>(deserializer: D) -> Result<Time, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Time, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Encode<'_, Postgres> for Time
impl Encode<'_, Postgres> for Time
Source§fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
fn size_hint(&self) -> usize
Source§fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
Writes the value of
self
into buf
in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
Source§impl<'q> Encode<'q, Sqlite> for Time
impl<'q> Encode<'q, Sqlite> for Time
Source§fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
fn encode_by_ref(&self, args: &mut Vec<SqliteArgumentValue<'q>>) -> IsNull
Source§fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNullwhere
Self: Sized,
Writes the value of
self
into buf
in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl From<NaiveDateTime> for Time
impl From<NaiveDateTime> for Time
Source§fn from(datetime: NaiveDateTime) -> Self
fn from(datetime: NaiveDateTime) -> Self
Converts to this type from the input type.
Source§impl TryFrom<SystemTime> for Time
impl TryFrom<SystemTime> for Time
Source§impl TryFrom<Time> for NaiveDateTime
impl TryFrom<Time> for NaiveDateTime
Source§impl Type<Postgres> for Time
impl Type<Postgres> for Time
Source§fn type_info() -> PgTypeInfo
fn type_info() -> PgTypeInfo
Returns the canonical SQL type for this Rust type. Read more
Source§fn compatible(ty: &PgTypeInfo) -> bool
fn compatible(ty: &PgTypeInfo) -> bool
Determines if this Rust type is compatible with the given SQL type. Read more
Source§impl Type<Sqlite> for Time
impl Type<Sqlite> for Time
Source§fn type_info() -> SqliteTypeInfo
fn type_info() -> SqliteTypeInfo
Returns the canonical SQL type for this Rust type. Read more
Source§fn compatible(ty: &SqliteTypeInfo) -> bool
fn compatible(ty: &SqliteTypeInfo) -> bool
Determines if this Rust type is compatible with the given SQL type. Read more
impl Copy for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Freeze for Time
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CustomError for T
impl<T> CustomError for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<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<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