pub struct LeapSecondsBuilder { /* private fields */ }Expand description
A builder for constructing custom LeapSeconds tables.
§Example
use leap_sec::prelude::*;
let table = LeapSeconds::builder()
.add(UtcUnixSeconds(63_072_000), 10) // 1972-01-01
.add(UtcUnixSeconds(78_796_800), 11) // 1972-07-01
.build()
.unwrap();
let tai = table.utc_to_tai(UtcUnixSeconds(70_000_000)).unwrap();
assert_eq!(tai, TaiSeconds(70_000_010));Implementations§
Source§impl LeapSecondsBuilder
impl LeapSecondsBuilder
Sourcepub fn add(self, utc: UtcUnixSeconds, tai_minus_utc: i32) -> Self
pub fn add(self, utc: UtcUnixSeconds, tai_minus_utc: i32) -> Self
Add a leap-second entry.
utc is the UTC Unix timestamp at which the offset takes effect.
tai_minus_utc is the cumulative TAI−UTC offset from this point forward.
Sourcepub const fn expires_at(self, at: UtcUnixSeconds) -> Self
pub const fn expires_at(self, at: UtcUnixSeconds) -> Self
Set an expiration timestamp for the table.
Sourcepub fn build(self) -> Result<LeapSeconds, Error>
pub fn build(self) -> Result<LeapSeconds, Error>
Build the leap-second table.
§Errors
Returns Error::InvalidTable if:
- The table is empty
- Timestamps are not monotonically increasing
Trait Implementations§
Source§impl Clone for LeapSecondsBuilder
impl Clone for LeapSecondsBuilder
Source§fn clone(&self) -> LeapSecondsBuilder
fn clone(&self) -> LeapSecondsBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LeapSecondsBuilder
impl Debug for LeapSecondsBuilder
Auto Trait Implementations§
impl Freeze for LeapSecondsBuilder
impl RefUnwindSafe for LeapSecondsBuilder
impl Send for LeapSecondsBuilder
impl Sync for LeapSecondsBuilder
impl Unpin for LeapSecondsBuilder
impl UnsafeUnpin for LeapSecondsBuilder
impl UnwindSafe for LeapSecondsBuilder
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