-/// If this function fails this is considered a bug. Please open an issue describing your
-/// platform and stating your current system time.
-///
-/// Note that this currently does nothing in `no_std` environments, because they don't have
-/// a `SystemTime` implementation.
-///
-/// # Panics
-/// If the check fails this function panics. By calling this function on startup you ensure that
-/// this wont happen at an arbitrary later point in time.
-pub fn check_platform() {
- #[cfg(feature = "std")]
- check_system_time_bounds();
-}
-
-#[cfg(feature = "std")]
-fn check_system_time_bounds() {
- // The upper and lower bounds of `SystemTime` are not part of its public contract and are
- // platform specific. That's why we have to test if our assumptions regarding these bounds
- // hold on the target platform.
- //
- // If this test fails on your platform, please don't use the library and open an issue
- // instead so we can resolve the situation. Currently this library is tested on:
- // * Linux (64bit)
- let fail_date = SystemTime::UNIX_EPOCH + Duration::from_secs(SYSTEM_TIME_MAX_UNIX_TIMESTAMP);
- let year = Duration::from_secs(60 * 60 * 24 * 365);
-
- // Make sure that the library will keep working for another year
- assert!(fail_date.duration_since(SystemTime::now()).unwrap() > year);
-
- let max_ts = PositiveTimestamp::from_unix_timestamp(
- SYSTEM_TIME_MAX_UNIX_TIMESTAMP - MAX_EXPIRY_TIME
- ).unwrap();
- let max_exp = ::ExpiryTime::from_seconds(MAX_EXPIRY_TIME).unwrap();
-
- assert_eq!(
- (max_ts.as_time() + *max_exp.as_duration()).duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(),
- SYSTEM_TIME_MAX_UNIX_TIMESTAMP
- );
-}
-