Skip to main content

dash_runtime/timing/
mod.rs

1//! Pure time arithmetic: UTC clock, `xs:dateTime`, UTCTiming, availability,
2//! live edge and PeriodStart. Nothing in this module reads a clock; every
3//! function takes the instants it needs as arguments.
4
5use thiserror::Error;
6
7pub mod availability;
8pub mod clock;
9pub mod datetime;
10pub mod live_edge;
11pub mod period;
12pub mod utc_timing;
13
14/// Why a clock sample could not be built.
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
16#[non_exhaustive]
17pub enum TimingError {
18    /// The response arrived before the request was sent.
19    #[error("response timestamp precedes the request timestamp")]
20    ExchangeReversed,
21    /// The round trip is too long to trust.
22    #[error("round trip of {rtt_us} us exceeds the {max_us} us limit")]
23    RttTooLarge {
24        /// Measured round trip.
25        rtt_us: u64,
26        /// Limit.
27        max_us: u64,
28    },
29    /// A UTC response body above the cap.
30    #[error("UTC response body exceeds {max} bytes")]
31    BodyTooLarge {
32        /// The cap.
33        max: usize,
34    },
35    /// A UTC response body that is not UTF-8.
36    #[error("UTC response body is not UTF-8")]
37    NotUtf8,
38    /// The scheme has no body time this core can read.
39    #[error("UTCTiming scheme {0} is not sampled from a response body")]
40    SchemeNotSampled(utc_timing::UtcScheme),
41    /// The time text was not accepted.
42    #[error(transparent)]
43    DateTime(#[from] datetime::DateTimeError),
44}