pub struct MySqlTime { /* private fields */ }
mysql
only.Expand description
Container for a MySQL TIME
value, which may be an interval or a time-of-day.
Allowed range is -838:59:59.0
to 838:59:59.0
.
If this value is used for a time-of-day, the range should be 00:00:00.0
to 23:59:59.999999
.
You can use Self::is_valid_time_of_day()
to check this easily.
Implementationsยง
sourceยงimpl MySqlTime
impl MySqlTime
sourcepub const MAX: MySqlTime = _
pub const MAX: MySqlTime = _
The MySqlTime
value corresponding to TIME '838:59:59.0'
(max value).
sourcepub const MIN: MySqlTime = _
pub const MIN: MySqlTime = _
The MySqlTime
value corresponding to TIME '-838:59:59.0'
(min value).
sourcepub fn new(
sign: MySqlTimeSign,
hours: u32,
minutes: u8,
seconds: u8,
microseconds: u32,
) -> Result<MySqlTime, MySqlTimeError>
pub fn new( sign: MySqlTimeSign, hours: u32, minutes: u8, seconds: u8, microseconds: u32, ) -> Result<MySqlTime, MySqlTimeError>
Construct a MySqlTime
that is valid for use as a TIME
value.
ยงErrors
MySqlTimeError::NegativeZero
if all fields are 0 butsign
isMySqlTimeSign::Negative
.MySqlTimeError::FieldRange
if any field is out of range:hours > 838
minutes > 59
seconds > 59
microseconds > 999_999
MySqlTimeError::SubsecondExcess
if the magnitude is less than one second over the maximum.- Durations 839 hours or greater are covered by
FieldRange
.
- Durations 839 hours or greater are covered by
sourcepub fn with_sign(self, sign: MySqlTimeSign) -> MySqlTime
pub fn with_sign(self, sign: MySqlTimeSign) -> MySqlTime
Update the sign
of this value.
sourcepub fn sign(&self) -> MySqlTimeSign
pub fn sign(&self) -> MySqlTimeSign
Return the sign (positive or negative) for this TIME value.
sourcepub fn is_zero(&self) -> bool
pub fn is_zero(&self) -> bool
Returns true
if self
is zero (equal to Self::ZERO
).
sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true
if self
is positive or zero, false
if negative.
sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true
if self
is negative, false
if positive or zero.
sourcepub fn is_valid_time_of_day(&self) -> bool
pub fn is_valid_time_of_day(&self) -> bool
Returns true
if this interval is a valid time-of-day.
If true
, the sign is positive and hours
is not greater than 23.
sourcepub fn hours(&self) -> u32
pub fn hours(&self) -> u32
Get the total number of hours in this interval, from 0 to 838.
If this value represents a time-of-day, the range is 0 to 23.
sourcepub fn microseconds(&self) -> u32
pub fn microseconds(&self) -> u32
Get the number of seconds in this interval, from 0 to 999,999.
sourcepub fn to_duration(&self) -> Option<Duration>
pub fn to_duration(&self) -> Option<Duration>
Convert this TIME value to a std::time::Duration
.
Returns None
if this value is negative (cannot be represented).
Trait Implementationsยง
sourceยงimpl<'q> Encode<'q, MySql> for MySqlTime
impl<'q> Encode<'q, MySql> for MySqlTime
sourceยงfn encode_by_ref(
&self,
buf: &mut <MySql as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn encode_by_ref( &self, buf: &mut <MySql as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn size_hint(&self) -> usize
sourceยงfn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self
into buf
in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
sourceยงimpl Ord for MySqlTime
impl Ord for MySqlTime
1.21.0 ยท sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
sourceยงimpl PartialOrd for MySqlTime
impl PartialOrd for MySqlTime
sourceยงimpl TryFrom<Duration> for MySqlTime
impl TryFrom<Duration> for MySqlTime
Convert MySqlTime
from std::time::Duration
.
ยงNote: Precision Truncation
Duration
supports nanosecond precision, but MySQL TIME
values only support microsecond
precision.
For simplicity, higher precision values are truncated when converting.
If you prefer another rounding mode instead, you should apply that to the Duration
first.
See also: MySQL Manual, section 13.2.6: Fractional Seconds in Time Values
ยงErrors:
Returns MySqlTimeError::FieldRange
if the given duration is longer than 838:59:59.999999
.
impl Copy for MySqlTime
impl Eq for MySqlTime
impl StructuralPartialEq for MySqlTime
Auto Trait Implementationsยง
impl Freeze for MySqlTime
impl RefUnwindSafe for MySqlTime
impl Send for MySqlTime
impl Sync for MySqlTime
impl Unpin for MySqlTime
impl UnwindSafe for MySqlTime
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
sourceยงunsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)sourceยงimpl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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
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> โ
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> โ
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