pub struct IntervalValue {
pub months: i32,
pub days: i32,
pub microseconds: i64,
}Expand description
Interval Value Type - PostgreSQL Compatible
Represents a time span that can be:
- Calendar-based (years, months)
- Clock-based (days, hours, minutes, seconds)
- Mixed (both calendar and clock components)
§Examples
- “1 year 2 months” -> months: 14
- “3 days 4 hours” -> days: 3, microseconds: 4 * 3600 * 1_000_000
- “1 year 2 days” -> months: 12, days: 2
Fields§
§months: i32Calendar months (can be negative)
days: i32Clock days (can be negative, separate from months for DST handling)
microseconds: i64Clock microseconds (can be negative and exceed 24 hours)
Implementations§
Source§impl IntervalValue
impl IntervalValue
Sourcepub const fn from_years(years: i32) -> Self
pub const fn from_years(years: i32) -> Self
Create interval from years
Sourcepub const fn from_months(months: i32) -> Self
pub const fn from_months(months: i32) -> Self
Create interval from months
Sourcepub const fn from_hours(hours: i64) -> Self
pub const fn from_hours(hours: i64) -> Self
Create interval from hours
Sourcepub const fn from_minutes(minutes: i64) -> Self
pub const fn from_minutes(minutes: i64) -> Self
Create interval from minutes
Sourcepub const fn from_seconds(seconds: i64) -> Self
pub const fn from_seconds(seconds: i64) -> Self
Create interval from seconds
Sourcepub const fn from_milliseconds(millis: i64) -> Self
pub const fn from_milliseconds(millis: i64) -> Self
Create interval from milliseconds
Sourcepub const fn from_microseconds(micros: i64) -> Self
pub const fn from_microseconds(micros: i64) -> Self
Create interval from microseconds
Sourcepub fn parse(s: &str) -> Result<Self, IntervalError>
pub fn parse(s: &str) -> Result<Self, IntervalError>
Parse interval from PostgreSQL format string
Supported formats:
- “1 year 2 months 3 days 4 hours 5 minutes 6 seconds”
- “1-2” (year-month)
- “3 4:05:06” (day time)
- “P1Y2M3DT4H5M6S” (ISO 8601)
Sourcepub const fn total_months(&self) -> i32
pub const fn total_months(&self) -> i32
Get total months (calendar component)
Sourcepub const fn total_days(&self) -> i32
pub const fn total_days(&self) -> i32
Get total days (clock component, excluding months)
Sourcepub const fn total_microseconds(&self) -> i64
pub const fn total_microseconds(&self) -> i64
Get total microseconds (clock component)
Sourcepub const fn months_component(&self) -> i32
pub const fn months_component(&self) -> i32
Get remaining months component (0-11)
Sourcepub const fn fractional_seconds(&self) -> i64
pub const fn fractional_seconds(&self) -> i64
Get fractional seconds (microseconds component)
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Check if interval is positive
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Check if interval is negative
Sourcepub fn to_iso8601(&self) -> String
pub fn to_iso8601(&self) -> String
Format as ISO 8601 duration
Sourcepub fn to_postgresql(&self) -> String
pub fn to_postgresql(&self) -> String
Format as PostgreSQL style string
Sourcepub const fn estimated_size(&self) -> usize
pub const fn estimated_size(&self) -> usize
Estimate memory usage
Trait Implementations§
Source§impl Add for IntervalValue
impl Add for IntervalValue
Source§impl Clone for IntervalValue
impl Clone for IntervalValue
impl Copy for IntervalValue
Source§impl Debug for IntervalValue
impl Debug for IntervalValue
Source§impl Default for IntervalValue
impl Default for IntervalValue
Source§impl<'de> Deserialize<'de> for IntervalValue
impl<'de> Deserialize<'de> for IntervalValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for IntervalValue
impl Display for IntervalValue
impl Eq for IntervalValue
Source§impl From<IntervalValue> for Value
impl From<IntervalValue> for Value
Source§fn from(value: IntervalValue) -> Self
fn from(value: IntervalValue) -> Self
Source§impl Hash for IntervalValue
impl Hash for IntervalValue
Source§impl Neg for IntervalValue
impl Neg for IntervalValue
Source§impl PartialEq for IntervalValue
impl PartialEq for IntervalValue
Source§impl Serialize for IntervalValue
impl Serialize for IntervalValue
impl StructuralPartialEq for IntervalValue
Auto Trait Implementations§
impl Freeze for IntervalValue
impl RefUnwindSafe for IntervalValue
impl Send for IntervalValue
impl Sync for IntervalValue
impl Unpin for IntervalValue
impl UnsafeUnpin for IntervalValue
impl UnwindSafe for IntervalValue
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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§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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more