6 releases

Uses new Rust 2024

0.2.3 Oct 7, 2025
0.2.2 Jun 22, 2025
0.1.1 Jun 4, 2025

#94 in Date and time

Download history 217/week @ 2025-07-19 130/week @ 2025-07-26 64/week @ 2025-08-02 90/week @ 2025-08-09 66/week @ 2025-08-16 72/week @ 2025-08-23 121/week @ 2025-08-30 88/week @ 2025-09-06 98/week @ 2025-09-13 252/week @ 2025-09-20 144/week @ 2025-09-27 353/week @ 2025-10-04 943/week @ 2025-10-11 866/week @ 2025-10-18 1435/week @ 2025-10-25 2263/week @ 2025-11-01

5,615 downloads per month

MIT license

45KB
907 lines

Library for clock and clock abstractions.

This library provides traits representing an abstract clock.

  • NowOnce, NowMut, Now, these are specialized versions of the Fn* traits. They represent the operation to retrieve the current time.
  • SleepOnce, SleepMut, Sleep, these are specialized versions of the Fn* traits. They represent the operation to create a timer resolved at a later time.

This crate also provides aliases and utility traits.

  • ErasedSleep: Sleep variant returning an opaque boxed future.
  • StdClock, Chrono04Clock: high-level traits
  • NowExt: helper methods

Horloge - clock abstraction for Rust

The horloge Rust crate defines trait for time sources (Now) and sleeping (Sleep). These traits allow to abstract over the concrete implementation. This enables writing generic code using the system clock when deployed or a virtual clock during tests.

This crate provides trait definitions, and implementation providing support for the major time libraries in the Rust ecosystem.

The name "horloge" means clock in french.

Integration

The intent is to provide integration with most libraries in the ecosystem. Here are the currently support libraries. Contributions are welcome.

Time model

Sleep scheduler

Licence

MIT

Dependencies

~2.9–6.5MB
~106K SLoC