Struct tai_time::TaiTime

source ·
pub struct TaiTime<const EPOCH_REF: i64> { /* private fields */ }
Expand description

Nanosecond-precision monotonic clock timestamp parametrized by its epoch.

A timestamp specifies a TAI point in time. It is represented as a 64-bit signed number of seconds and a positive number of nanoseconds, counted with reference to the epoch specified by the generic parameter.

EPOCH_REF defines the epoch via its signed distance in seconds from 1970-01-01 00:00:00 TAI.

See also: MonotonicTime, GpsTime, GstTime, BdtTime, Tai1958Time and Tai1972Time.

§Examples

use std::time::Duration;
use tai_time::TaiTime;

// A timestamp type with an epoch at 1970:01:01 00:02:03 TAI.
type MyCustomTime = TaiTime<123>;

// A timestamp set to 2009-02-13 23:33:33.333333333 TAI.
let mut timestamp = MyCustomTime::new(1_234_567_890, 333_333_333).unwrap();

// Increment the timestamp by 123.456s.
timestamp += Duration::new(123, 456_000_000);

assert_eq!(timestamp, MyCustomTime::new(1_234_568_013, 789_333_333).unwrap());
assert_eq!(timestamp.as_secs(), 1_234_568_013);
assert_eq!(timestamp.subsec_nanos(), 789_333_333);

Implementations§

source§

impl<const EPOCH_REF: i64> TaiTime<EPOCH_REF>

source

pub const EPOCH: Self = _

The reference epoch, which by definition is always a null timestamp.

source

pub const MIN: Self = _

The minimum possible TaiTime timestamp.

source

pub const MAX: Self = _

The maximum possible TaiTime timestamp.

source

pub const fn new(secs: i64, subsec_nanos: u32) -> Option<Self>

Creates a timestamp from its parts.

The number of seconds is relative to the epoch. The number of nanoseconds is always positive and always points towards the future.

Returns None if the number of nanoseconds is greater than 999 999 999.

§Example

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

// A timestamp set to 2009-02-13 23:31:30.987654321 TAI.
let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();

// A timestamp set 0.5s in the past of the epoch.
let timestamp = MonotonicTime::new(-1, 500_000_000).unwrap();
assert_eq!(timestamp, MonotonicTime::EPOCH - Duration::from_millis(500));
source

pub fn now() -> Self

Available on crate feature tai_clock and (Android or Emscripten or Fuchsia or Linux) only.

Creates a timestamp from the TAI system clock.

This is currently only supported on Linux and relies on the clock_gettime system call with a CLOCK_TAI clock ID.

The use of the Linux TAI clock is subject to several caveats, most importantly:

  1. On many default-configured Linux systems, the offset between TAI and UTC is arbitrarily set to 0 at boot time, in which case the TAI system clock will actually only differ from UTC time by the number of leap seconds introduced after the system was booted (most likely, 0).
  2. Some systems are configured to perform leap second smearing by altering the rate of the system clock over a 24h period so as to avoid the leap second discontinuity; this entirely defeats the purpose of the TAI clock which becomes effectively synchronized to the (leap-smeared) UTC system clock.

The first issue can be easily remedied, however, by using chrony and, if necessary, making sure that the leapsectz parameter in chrony.conf is set to right/UTC. Alternatively, one can specify the leapfile path in ntp.conf or set the TAI offset directly with a call to adjtimex or ntp_adjtime.

§Panics

Panics if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

See try_now for a non-panicking alternative.

Note that this constructor will never fail with the MonotonicTime alias as it shares the same epoch as the TAI system clock.

source

pub fn try_now() -> Result<Self, OutOfRangeError>

Available on crate feature tai_clock and (Android or Emscripten or Fuchsia or Linux) only.

Creates a timestamp from the TAI system clock.

This is a non-panicking alternative to now.

When using the MonotonicTime alias, use now since it will never fail.

Returns an error if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

source

pub fn now_from_utc(leap_secs: i64) -> Self

Available on crate feature std only.

Creates a timestamp from the UTC system clock.

This is a shorthand for from_system_time(&SystemTime::now(), leap_secs).

The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

Beware that the behavior of the system clock near a leap second shouldn’t be relied upon, where near might actually stand for the whole 24h period preceding a leap second due to the possible use of the so-called leap second smearing strategy.

See also: from_system_time.

§Panics

Panics if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

See try_now_from_utc for a non-panicking alternative.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::MonotonicTime;

// Compute the current timestamp assuming that the current difference
// between TAI and UTC time is 37s.
let timestamp = MonotonicTime::now_from_utc(37);
source

pub fn try_now_from_utc(leap_secs: i64) -> Result<Self, OutOfRangeError>

Available on crate feature std only.

Creates a timestamp from the UTC system clock.

This is a non-panicking alternative to now_from_utc.

Returns an error if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

source

pub const fn try_from_date_time( year: i32, month: u8, day: u8, hour: u8, min: u8, sec: u8, nano: u32 ) -> Result<Self, DateTimeError>

Creates a timestamp from a date-time representation.

The first argument is the proleptic Gregorian year. It follows the ISO 8601 interpretation of year 0 as year 1 BC.

Other arguments follow the usual calendar convention, with month and day numerals starting at 1.

Note that the proleptic Gregorian calendar extrapolates dates before 1582 using the conventional leap year rules, and considers year 0 as a leap year. Proleptic Gregorian dates may therefore differ from those of the Julian calendar.

Returns an error if any of the arguments is invalid, or if the calculated timestamp is outside the representable range.

May also return an error if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch, and is impossible with the provided TaiTime aliases (MonotonicTime, GpsTime, GstTime, BdtTime, Tai1958Time or Tai1972Time).

§Example

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

// A timestamp set to 2009-02-13 23:31:30.987654321 TAI.
let timestamp = MonotonicTime::try_from_date_time(2009, 2, 13, 23, 31, 30, 987_654_321);
assert_eq!(timestamp, Ok(MonotonicTime::new(1_234_567_890, 987_654_321).unwrap()));
source

pub const fn from_unix_timestamp( secs: i64, subsec_nanos: u32, leap_secs: i64 ) -> Self

Creates a TAI timestamp from a Unix timestamp.

The last argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

This method tolerates Unix timestamps that account for leap seconds by adding them to the nanosecond field: all nanoseconds in excess of 999 999 999 will carry over into the seconds.

Note that there is no unanimous consensus regarding the conversion between TAI and Unix timestamps prior to 1972.

§Panics

Panics if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

See try_from_unix_timestamp for a non-panicking alternative.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::MonotonicTime;

// Creates a timestamp corresponding to 2001-09-15 05:05:00.005 UTC,
// accounting for the +32s difference between UAI and UTC on 2001-09-15.
assert_eq!(
    MonotonicTime::from_unix_timestamp(1_000_530_300, 5_000_000, 32),
    MonotonicTime::new(1_000_530_332, 5_000_000).unwrap()
);
source

pub const fn try_from_unix_timestamp( secs: i64, subsec_nanos: u32, leap_secs: i64 ) -> Result<Self, OutOfRangeError>

Creates a TAI timestamp from a Unix timestamp.

This is a non-panicking alternative to from_unix_timestamp.

Returns an error if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

source

pub fn from_system_time(system_time: &SystemTime, leap_secs: i64) -> Self

Available on crate feature std only.

Creates a TAI timestamp from a SystemTime timestamp.

The last argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

§Panics

Panics if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

See try_from_system_time for a non-panicking alternative.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::{Duration, SystemTime};
use tai_time::MonotonicTime;

// Creates a timestamp corresponding to 2001-09-15 05:05:00.005 UTC,
// accounting for the +32s difference between UAI and UTC on 2001-09-15.
let system_time = SystemTime::UNIX_EPOCH + Duration::new(1_000_530_300, 5_000_000);
assert_eq!(
    MonotonicTime::from_system_time(&system_time, 32),
    MonotonicTime::new(1_000_530_332, 5_000_000).unwrap()
);
source

pub fn try_from_system_time( system_time: &SystemTime, leap_secs: i64 ) -> Result<Self, OutOfRangeError>

Available on crate feature std only.

Creates a TAI timestamp from a SystemTime timestamp.

This is a non-panicking alternative to from_system_time.

Returns an error if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

source

pub const fn from_chrono_date_time<Tz: TimeZone>( date_time: &DateTime<Tz>, leap_secs: i64 ) -> Self

Available on crate feature chrono only.

Creates a timestamp from a chrono::DateTime.

The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

While no error will be reported, this method should not be considered appropriate for timestamps in the past of 1972.

§Panics

Panics if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch while the range of a chrono::DateTime spans from year -262144 to year 262143.

See try_from_chrono_date_time for a non-panicking alternative.

Note that the conversion will never fail with the provided TaiTime aliases (MonotonicTime, GpsTime, GstTime, BdtTime, Tai1958Time or Tai1972Time).

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::MonotonicTime;
use chrono::DateTime;

let tai_date_time: MonotonicTime = "2001-09-15 05:05:32.005".parse().unwrap();
let chrono_date_time = DateTime::parse_from_rfc3339("2001-09-15T05:05:00.005Z").unwrap();

assert_eq!(
    MonotonicTime::from_chrono_date_time(&chrono_date_time, 32),
    tai_date_time
);
source

pub const fn try_from_chrono_date_time<Tz: TimeZone>( date_time: &DateTime<Tz>, leap_secs: i64 ) -> Result<Self, OutOfRangeError>

Available on crate feature chrono only.

Creates a timestamp from a chrono::DateTime.

This is a non-panicking alternative to from_chrono_date_time.

When using the provided TaiTime aliases (MonotonicTime, GpsTime, GstTime, BdtTime, Tai1958Time or Tai1972Time), use from_chrono_date_time since the conversion will never fail.

Returns an error if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch while the range of a chrono::DateTime spans from year -262144 to year 262143.

source

pub const fn as_secs(&self) -> i64

Returns the signed value of the closest second boundary that is equal to or lower than the timestamp, relative to the EPOCH.

This value is the same as the one that would be provided to construct the timestamp with new().

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert_eq!(timestamp.as_secs(), 1_234_567_890);

let timestamp = MonotonicTime::EPOCH - Duration::new(3, 500_000_000);
assert_eq!(timestamp.as_secs(), -4);
source

pub const fn subsec_nanos(&self) -> u32

Returns the sub-second fractional part in nanoseconds.

Note that nanoseconds always point towards the future even if the date is in the past of the EPOCH.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::MonotonicTime;

let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert_eq!(timestamp.subsec_nanos(), 987_654_321);
source

pub const fn as_unix_secs(&self, leap_secs: i64) -> Option<i64>

Returns the number of seconds of the corresponding Unix timestamp.

The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

This method merely subtracts the offset from the value returned by as_secs(); its main purpose is to prevent mistakes regarding the direction in which the offset should be applied.

The nanosecond part of a Unix timestamp can be simply retrieved with subsec_nanos() since UTC and TAI differ by a whole number of seconds since 1972.

Note that there is no unanimous consensus regarding the conversion between TAI and Unix timestamps prior to 1972.

Returns None if the result cannot be represented as a Unix timestamp. This is a highly unlikely occurrence since the range of a Unix timestamp spans more than ±292 billion years from 1970-01-01 00:00:00 UTC.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::MonotonicTime;

// Set the date to 2000-01-01 00:00:00 TAI.
let timestamp = MonotonicTime::new(946_684_800, 0).unwrap();

// Convert to a Unix timestamp, accounting for the +32s difference between
// TAI and UTC on 2000-01-01.
assert_eq!(
    timestamp.as_unix_secs(32),
    Some(946_684_768)
);
source

pub const fn to_tai_time<const OTHER_EPOCH_REF: i64>( &self ) -> Option<TaiTime<OTHER_EPOCH_REF>>

Returns a timestamp with a different reference epoch.

Returns None if the result is outside the representable range for the resulting timestamp. This is a highly unlikely occurrence since the range of a TaiTime spans more than ±292 billion years from its epoch.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::{GpsTime, MonotonicTime};

// Set the date to 2000-01-01 00:00:00 TAI.
let timestamp = MonotonicTime::new(946_684_800, 0).unwrap();

// Convert to a GPS timestamp.
let gps_timestamp: GpsTime = timestamp.to_tai_time().unwrap();
assert_eq!(
    gps_timestamp,
    GpsTime::new(630_719_981, 0).unwrap()
);
source

pub fn to_system_time(&self, leap_secs: i64) -> Option<SystemTime>

Available on crate feature std only.

Returns a SystemTime based on the timestamp.

The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

While no error will be reported, this method should not be considered appropriate for timestamps in the past of 1972.

Returns None if the resulting timestamp predates the Unix epoch (1970-01-01 00:00:00 UTC) or cannot be otherwise represented as a SystemTime.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::{Duration, SystemTime};
use tai_time::MonotonicTime;

// Set the date to 2000-01-01 00:00:00.123 TAI.
let timestamp = MonotonicTime::new(946_684_800, 123_000_000).unwrap();

// Obtain a `SystemTime`, accounting for the +32s difference between
// TAI and UTC on 2000-01-01.
assert_eq!(
    timestamp.to_system_time(32),
    Some(SystemTime::UNIX_EPOCH + Duration::new(946_684_768, 123_000_000))
);
source

pub fn to_chrono_date_time(&self, leap_secs: i64) -> Option<DateTime<Utc>>

Available on crate feature chrono only.

Returns a chrono::DateTime based on the timestamp.

The argument is the difference between TAI and UTC time in seconds (a.k.a. leap seconds) applicable at the date represented by the timestamp. For reference, this offset has been +37s since 2017-01-01, a value which is to remain valid until at least 2024-12-28. See the official IERS bulletin C for leap second announcements or the IERS table for current and historical values.

While no error will be reported, this method should not be considered appropriate for timestamps in the past of 1972.

Returns None if the resulting timestamp cannot be represented by a chrono::DateTime, which may occur if the date predates year -262144 or postdates year 262143.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use tai_time::MonotonicTime;

// Set the date to 2000-01-01 00:00:00.123 TAI (1999-12-31 23:59:28.123 UTC).
let timestamp = MonotonicTime::new(946_684_800, 123_000_000).unwrap();

// Obtain a `chrono::DateTime`, accounting for the +32s difference between
// TAI and UTC on 2000-01-01.
let date_time = timestamp.to_chrono_date_time(32).unwrap();
assert_eq!(
    date_time.to_string(),
    "1999-12-31 23:59:28.123 UTC"
);
source

pub const fn checked_add(self, rhs: Duration) -> Option<Self>

Adds a duration to a timestamp, checking for overflow.

Returns None if overflow occurred.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert!(timestamp.checked_add(Duration::new(10, 123_456_789)).is_some());
assert!(timestamp.checked_add(Duration::MAX).is_none());
source

pub const fn checked_sub(self, rhs: Duration) -> Option<Self>

Subtracts a duration from a timestamp, checking for overflow.

Returns None if overflow occurred.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

let timestamp = MonotonicTime::new(1_234_567_890, 987_654_321).unwrap();
assert!(timestamp.checked_sub(Duration::new(10, 123_456_789)).is_some());
assert!(timestamp.checked_sub(Duration::MAX).is_none());
source

pub const fn duration_since(self, earlier: Self) -> Duration

Subtracts a timestamp from another timestamp.

Consider using checked_duration_since if the relative ordering of the timestamps is not known with certainty.

§Panics

Panics if the argument lies in the future of self.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

let timestamp_earlier = MonotonicTime::new(1_234_567_879, 987_654_321).unwrap();
let timestamp_later = MonotonicTime::new(1_234_567_900, 123_456_789).unwrap();
assert_eq!(
    timestamp_later.duration_since(timestamp_earlier),
    Duration::new(20, 135_802_468)
);
source

pub const fn checked_duration_since(self, earlier: Self) -> Option<Duration>

Computes the duration elapsed between a timestamp and an earlier timestamp, checking that the timestamps are appropriately ordered.

Returns None if the argument lies in the future of self.

§Examples

(Shown here for MonotonicTime, an alias for TaiTime<0>)

use std::time::Duration;
use tai_time::MonotonicTime;

let timestamp_earlier = MonotonicTime::new(1_234_567_879, 987_654_321).unwrap();
let timestamp_later = MonotonicTime::new(1_234_567_900, 123_456_789).unwrap();
assert!(timestamp_later.checked_duration_since(timestamp_earlier).is_some());
assert!(timestamp_earlier.checked_duration_since(timestamp_later).is_none());

Trait Implementations§

source§

impl<const EPOCH_REF: i64> Add<Duration> for TaiTime<EPOCH_REF>

source§

fn add(self, other: Duration) -> Self

Adds a duration to a timestamp.

§Panics

This function panics if the resulting timestamp cannot be represented.

See TaiTime::checked_add for a non-panicking alternative.

§

type Output = TaiTime<EPOCH_REF>

The resulting type after applying the + operator.
source§

impl<const EPOCH_REF: i64> AddAssign<Duration> for TaiTime<EPOCH_REF>

source§

fn add_assign(&mut self, other: Duration)

Increments the timestamp by a duration.

§Panics

This function panics if the resulting timestamp cannot be represented.

source§

impl<const EPOCH_REF: i64> Clone for TaiTime<EPOCH_REF>

source§

fn clone(&self) -> TaiTime<EPOCH_REF>

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<const EPOCH_REF: i64> Debug for TaiTime<EPOCH_REF>

source§

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

Formats the value using the given formatter. Read more
source§

impl<const EPOCH_REF: i64> Default for TaiTime<EPOCH_REF>

source§

fn default() -> TaiTime<EPOCH_REF>

Returns the “default value” for a type. Read more
source§

impl<'de, const EPOCH_REF: i64> Deserialize<'de> for TaiTime<EPOCH_REF>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<const EPOCH_REF: i64> Display for TaiTime<EPOCH_REF>

source§

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

Displays the TAI timestamp as an RFC3339-like date-time.

source§

impl<const EPOCH_REF: i64> Format for TaiTime<EPOCH_REF>
where i64: Format,

source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
source§

impl<const EPOCH_REF: i64> FromStr for TaiTime<EPOCH_REF>

source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses an RFC3339-like TAI date-time with signed years. Since TAI is timezone-independent, time zones and offsets suffixes are invalid.

Expected format:

[±][Y]...[Y]YYYY-MM-DD hh:mm:ss[.d[d]...[d]]

or:

[±][Y]...[Y]YYYY-MM-DD'T'hh:mm:ss[.d[d]...[d]]

where delimiter T between date and time may also be a lowercase t.

The year may take any value within ±i32::MAX.

§

type Err = ParseDateTimeError

The associated error which can be returned from parsing.
source§

impl<const EPOCH_REF: i64> Hash for TaiTime<EPOCH_REF>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<const EPOCH_REF: i64> Ord for TaiTime<EPOCH_REF>

source§

fn cmp(&self, other: &TaiTime<EPOCH_REF>) -> 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<const EPOCH_REF: i64> PartialEq for TaiTime<EPOCH_REF>

source§

fn eq(&self, other: &TaiTime<EPOCH_REF>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const EPOCH_REF: i64> PartialOrd for TaiTime<EPOCH_REF>

source§

fn partial_cmp(&self, other: &TaiTime<EPOCH_REF>) -> 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

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

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

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const EPOCH_REF: i64> Serialize for TaiTime<EPOCH_REF>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<const EPOCH_REF: i64> Sub<Duration> for TaiTime<EPOCH_REF>

source§

fn sub(self, other: Duration) -> Self

Subtracts a duration from a timestamp.

§Panics

This function panics if the resulting timestamp cannot be represented.

See TaiTime::checked_sub for a non-panicking alternative.

§

type Output = TaiTime<EPOCH_REF>

The resulting type after applying the - operator.
source§

impl<const EPOCH_REF: i64> SubAssign<Duration> for TaiTime<EPOCH_REF>

source§

fn sub_assign(&mut self, other: Duration)

Decrements the timestamp by a duration.

§Panics

This function panics if the resulting timestamp cannot be represented.

source§

impl<const EPOCH_REF: i64> Copy for TaiTime<EPOCH_REF>

source§

impl<const EPOCH_REF: i64> Eq for TaiTime<EPOCH_REF>

source§

impl<const EPOCH_REF: i64> StructuralPartialEq for TaiTime<EPOCH_REF>

Auto Trait Implementations§

§

impl<const EPOCH_REF: i64> Freeze for TaiTime<EPOCH_REF>

§

impl<const EPOCH_REF: i64> RefUnwindSafe for TaiTime<EPOCH_REF>

§

impl<const EPOCH_REF: i64> Send for TaiTime<EPOCH_REF>

§

impl<const EPOCH_REF: i64> Sync for TaiTime<EPOCH_REF>

§

impl<const EPOCH_REF: i64> Unpin for TaiTime<EPOCH_REF>

§

impl<const EPOCH_REF: i64> UnwindSafe for TaiTime<EPOCH_REF>

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,