pub enum Error {
OutOfRange {
requested: i64,
valid_start: i64,
valid_end: i64,
},
TableExpired {
expires_at: i64,
},
InvalidTable {
detail: &'static str,
},
}Expand description
Errors that can occur during leap-second conversions or table construction.
All conversion methods on LeapSeconds return
Result<T, Error>. Pattern-match to handle specific cases:
§Example
use leap_sec::prelude::*;
let leaps = LeapSeconds::known();
match leaps.utc_to_tai(UtcUnixSeconds(0)) {
Ok(tai) => println!("TAI: {tai}"),
Err(Error::OutOfRange { requested, valid_start, .. }) => {
println!("{requested} is before {valid_start}");
}
Err(e) => println!("other error: {e}"),
}Variants§
OutOfRange
The requested timestamp is before the first entry in the leap-second table.
Returned by LeapSeconds::utc_to_tai,
LeapSeconds::tai_to_utc, and all
other conversion and offset methods when the input is outside the table’s
valid range.
Fields
TableExpired
The leap-second table has expired.
Reserved for future use when tables parsed from IERS files carry
expiration timestamps. The built-in LeapSeconds::known()
table never produces this error.
InvalidTable
The table data is invalid (used during builder validation).
Returned by LeapSecondsBuilder::build()
when the table is empty or timestamps are not monotonically increasing.
Trait Implementations§
Source§impl Display for Error
Formats the error with a human-readable message.
impl Display for Error
Formats the error with a human-readable message.
OutOfRange:"timestamp {requested} is outside the leap-second table range [{start}, {end}]"TableExpired:"leap-second table expired at {expires_at}; load a newer table or update the crate"InvalidTable:"invalid leap-second table: {detail}"
Source§impl Error for Error
Available on crate feature std only.Enables use as Box<dyn std::error::Error> and in error-handling chains.
impl Error for Error
std only.Enables use as Box<dyn std::error::Error> and in error-handling chains.
Available only with the std feature (enabled by default).
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()