Struct sqlx_mysql::types::MySqlTime

source ·
pub struct MySqlTime { /* private fields */ }
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: Self = _

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

source

pub const MAX: Self = _

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

source

pub const MIN: Self = _

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<Self, MySqlTimeError>

Construct a MySqlTime that is valid for use as a TIME value.

§Errors
source

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

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

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<Self, BoxDynError>

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

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

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 + Send + Sync>>
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: &Self) -> 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.

§

type Error = MySqlTimeError

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

fn try_from(value: Duration) -> Result<Self, Self::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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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