Struct sqlx::mysql::types::MySqlTime

source ยท
pub struct MySqlTime { /* private fields */ }
Available on crate feature 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

source

pub const ZERO: MySqlTime = _

The MySqlTime value corresponding to TIME '0:00:00.0' (zero).

source

pub const MAX: MySqlTime = _

The MySqlTime value corresponding to TIME '838:59:59.0' (max value).

source

pub const MIN: MySqlTime = _

The MySqlTime value corresponding to TIME '-838:59:59.0' (min value).

source

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
source

pub fn with_sign(self, sign: MySqlTimeSign) -> MySqlTime

Update the sign of this value.

source

pub fn sign(&self) -> MySqlTimeSign

Return the sign (positive or negative) for this TIME value.

source

pub fn is_zero(&self) -> bool

Returns true if self is zero (equal to Self::ZERO).

source

pub fn is_positive(&self) -> bool

Returns true if self is positive or zero, false if negative.

source

pub fn is_negative(&self) -> bool

Returns true if self is negative, false if positive or zero.

source

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.

source

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.

source

pub fn minutes(&self) -> u8

Get the number of minutes in this interval, from 0 to 59.

source

pub fn seconds(&self) -> u8

Get the number of seconds in this interval, from 0 to 59.

source

pub fn microseconds(&self) -> u32

Get the number of seconds in this interval, from 0 to 999,999.

source

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 Clone for MySqlTime

sourceยง

fn clone(&self) -> MySqlTime

Returns a copy of the value. Read more
1.0.0 ยท sourceยง

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

Performs copy-assignment from source. Read more
sourceยง

impl Debug for MySqlTime

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

impl<'r> Decode<'r, MySql> for MySqlTime

sourceยง

fn decode( value: <MySql as Database>::ValueRef<'r>, ) -> Result<MySqlTime, Box<dyn Error + Sync + Send>>

Decode a new value of this type using a raw value from the database.
sourceยง

impl Display for MySqlTime

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

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>>

Writes the value of self into buf without moving self. Read more
sourceยง

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,

Writes the value of self into buf in the expected format for the database.
sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

sourceยง

impl Ord for MySqlTime

sourceยง

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

This method returns an Ordering between self and other. Read more
1.21.0 ยท sourceยง

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

Compares and returns the maximum of two values. Read more
1.21.0 ยท sourceยง

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

Compares and returns the minimum of two values. Read more
1.50.0 ยท sourceยง

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

Restrict a value to a certain interval. Read more
sourceยง

impl PartialEq for MySqlTime

sourceยง

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท 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 MySqlTime

sourceยง

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 ยท 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 ยท 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 ยท 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 ยท 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 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.

sourceยง

type Error = MySqlTimeError

The type returned in the event of a conversion error.
sourceยง

fn try_from( value: Duration, ) -> Result<MySqlTime, <MySqlTime as TryFrom<Duration>>::Error>

Performs the conversion.
sourceยง

impl TryFrom<Duration> for MySqlTime

sourceยง

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
sourceยง

fn try_from( value: Duration, ) -> Result<MySqlTime, <MySqlTime as TryFrom<Duration>>::Error>

Performs the conversion.
sourceยง

impl TryFrom<MySqlTime> for NaiveTime

sourceยง

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
sourceยง

fn try_from( time: MySqlTime, ) -> Result<NaiveTime, <NaiveTime as TryFrom<MySqlTime>>::Error>

Performs the conversion.
sourceยง

impl TryFrom<MySqlTime> for Time

sourceยง

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
sourceยง

fn try_from( time: MySqlTime, ) -> Result<Time, <Time as TryFrom<MySqlTime>>::Error>

Performs the conversion.
sourceยง

impl TryFrom<TimeDelta> for MySqlTime

sourceยง

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
sourceยง

fn try_from( value: TimeDelta, ) -> Result<MySqlTime, <MySqlTime as TryFrom<TimeDelta>>::Error>

Performs the conversion.
sourceยง

impl Type<MySql> for MySqlTime

sourceยง

fn type_info() -> MySqlTypeInfo

Returns the canonical SQL type for this Rust type. Read more
sourceยง

fn compatible(ty: &<DB as Database>::TypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
sourceยง

impl Copy for MySqlTime

sourceยง

impl Eq for MySqlTime

sourceยง

impl StructuralPartialEq for MySqlTime

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, dst: *mut T)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
sourceยง

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

sourceยง

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

Compare self to key and return their ordering.
sourceยง

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

sourceยง

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

Checks if this value is equivalent to the given key. Read more
sourceยง

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

sourceยง

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> Instrument for T

sourceยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
sourceยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

sourceยง

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 more
sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

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
sourceยง

impl<T> Same for T

sourceยง

type Output = T

Should always be Self
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ยง

default 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<V, T> VZip<V> for T
where V: MultiLane<T>,

sourceยง

fn vzip(self) -> V

sourceยง

impl<T> WithSubscriber for T

sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more