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 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::NegativeZeroif all fields are 0 butsignisMySqlTimeSign::Negative.MySqlTimeError::FieldRangeif any field is out of range:hours > 838minutes > 59seconds > 59microseconds > 999_999
MySqlTimeError::SubsecondExcessif 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
Convert MySqlTime from std::time::Duration.
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ยง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ยง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