Skip to main content

cordis_timer/
lib.rs

1//! Cordis Timer: complete generation-owned time operations.
2//!
3//! Timer owns scheduling, monotonic deadlines, cancellation outcomes, and
4//! operation delivery. Core sees only generic generation cleanup obligations.
5
6mod shapes;
7
8pub use shapes::{Interval, Sleep, Timeout, TimeoutOutcome, TimerExt};
9
10/// Generation cleanup cancelled an already-constructed timer operation.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
12#[error("timer cancelled")]
13pub struct TimerCancelled;
14
15/// Why a timer operation could not be registered. Every variant is a
16/// synchronous pre-delivery refusal: no operation is returned.
17#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
18#[non_exhaustive]
19pub enum TimerRegistrationError {
20    /// The selected Context generation is closed to new cleanup.
21    #[error("the context's fiber generation is inactive")]
22    InactiveContext,
23    /// No usable Tokio time environment is current.
24    #[error("no usable timer environment is current")]
25    TimerUnavailable,
26    /// Interval periods must be nonzero.
27    #[error("interval period must be nonzero")]
28    ZeroPeriod,
29    /// The requested monotonic deadline cannot be represented.
30    #[error("timer deadline is out of range")]
31    DeadlineOutOfRange,
32}