pub struct Duration { /* private fields */ }
Expand description
It stores the duration using a pair of a YearMonthDuration
and a DayTimeDuration
.
Implementations§
Source§impl Duration
impl Duration
pub const MAX: Duration
pub const MIN: Duration
pub fn new( months: impl Into<i64>, seconds: impl Into<Decimal>, ) -> Result<Duration, OppositeSignInDurationComponentsError>
pub fn year_month(&self) -> YearMonthDuration
pub fn day_time(&self) -> DayTimeDuration
pub fn from_be_bytes(bytes: [u8; 24]) -> Duration
pub const fn all_months(self) -> i64
pub const fn all_seconds(self) -> Decimal
pub fn to_be_bytes(self) -> [u8; 24]
Sourcepub fn checked_add(
self,
rhs: impl Into<Duration>,
) -> Result<Duration, ThinError>
pub fn checked_add( self, rhs: impl Into<Duration>, ) -> Result<Duration, ThinError>
op:add-yearMonthDurations and op:add-dayTimeDurations
Returns Err
in case of overflow (FODT0002
).
Sourcepub fn checked_sub(
self,
rhs: impl Into<Duration>,
) -> Result<Duration, ThinError>
pub fn checked_sub( self, rhs: impl Into<Duration>, ) -> Result<Duration, ThinError>
op:subtract-yearMonthDurations and op:subtract-dayTimeDurations
Returns Err
in case of overflow (FODT0002
).
Sourcepub fn checked_neg(self) -> Result<Duration, ThinError>
pub fn checked_neg(self) -> Result<Duration, ThinError>
Unary negation.
Returns Err
in case of overflow (FODT0002
).
Sourcepub fn is_identical_with(self, other: Duration) -> bool
pub fn is_identical_with(self, other: Duration) -> bool
Checks if the two values are identical.
Trait Implementations§
Source§impl From<DayTimeDuration> for Duration
impl From<DayTimeDuration> for Duration
Source§fn from(value: DayTimeDuration) -> Duration
fn from(value: DayTimeDuration) -> Duration
Converts to this type from the input type.
Source§impl<'data> From<Duration> for TypedValueRef<'data>
impl<'data> From<Duration> for TypedValueRef<'data>
Source§fn from(value: Duration) -> TypedValueRef<'data>
fn from(value: Duration) -> TypedValueRef<'data>
Converts to this type from the input type.
Source§impl From<TimezoneOffset> for Duration
impl From<TimezoneOffset> for Duration
Source§fn from(value: TimezoneOffset) -> Duration
fn from(value: TimezoneOffset) -> Duration
Converts to this type from the input type.
Source§impl From<YearMonthDuration> for Duration
impl From<YearMonthDuration> for Duration
Source§fn from(value: YearMonthDuration) -> Duration
fn from(value: YearMonthDuration) -> Duration
Converts to this type from the input type.
Source§impl PartialEq<DayTimeDuration> for Duration
impl PartialEq<DayTimeDuration> for Duration
Source§impl PartialEq<Duration> for DayTimeDuration
impl PartialEq<Duration> for DayTimeDuration
Source§impl PartialEq<Duration> for YearMonthDuration
impl PartialEq<Duration> for YearMonthDuration
Source§impl PartialEq<YearMonthDuration> for Duration
impl PartialEq<YearMonthDuration> for Duration
Source§impl PartialOrd<DayTimeDuration> for Duration
impl PartialOrd<DayTimeDuration> for Duration
Source§impl PartialOrd<Duration> for DayTimeDuration
impl PartialOrd<Duration> for DayTimeDuration
Source§impl PartialOrd<Duration> for YearMonthDuration
impl PartialOrd<Duration> for YearMonthDuration
Source§impl PartialOrd<YearMonthDuration> for Duration
impl PartialOrd<YearMonthDuration> for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl TryFrom<Duration> for DayTimeDuration
impl TryFrom<Duration> for DayTimeDuration
Source§type Error = DurationOverflowError
type Error = DurationOverflowError
The type returned in the event of a conversion error.
Source§fn try_from(
value: Duration,
) -> Result<DayTimeDuration, <DayTimeDuration as TryFrom<Duration>>::Error>
fn try_from( value: Duration, ) -> Result<DayTimeDuration, <DayTimeDuration as TryFrom<Duration>>::Error>
Performs the conversion.
Source§impl TryFrom<Duration> for TimezoneOffset
impl TryFrom<Duration> for TimezoneOffset
Source§type Error = InvalidTimezoneError
type Error = InvalidTimezoneError
The type returned in the event of a conversion error.
Source§fn try_from(
value: Duration,
) -> Result<TimezoneOffset, <TimezoneOffset as TryFrom<Duration>>::Error>
fn try_from( value: Duration, ) -> Result<TimezoneOffset, <TimezoneOffset as TryFrom<Duration>>::Error>
Performs the conversion.
Source§impl TryFrom<Duration> for YearMonthDuration
impl TryFrom<Duration> for YearMonthDuration
Source§type Error = DurationOverflowError
type Error = DurationOverflowError
The type returned in the event of a conversion error.
Source§fn try_from(
value: Duration,
) -> Result<YearMonthDuration, <YearMonthDuration as TryFrom<Duration>>::Error>
fn try_from( value: Duration, ) -> Result<YearMonthDuration, <YearMonthDuration as TryFrom<Duration>>::Error>
Performs the conversion.
impl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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 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>
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