#duration #instant #const #compile-time #time

no-std fugit

Time library for embedded targets with ease-of-use and performance first

11 releases

0.3.7 Jun 6, 2023
0.3.6 Jun 23, 2022
0.3.5 Feb 14, 2022
0.3.3 Dec 25, 2021
0.1.4 Oct 31, 2021

#67 in Embedded development

Download history 16241/week @ 2024-01-24 13960/week @ 2024-01-31 15270/week @ 2024-02-07 13823/week @ 2024-02-14 15396/week @ 2024-02-21 14434/week @ 2024-02-28 16128/week @ 2024-03-06 15219/week @ 2024-03-13 16402/week @ 2024-03-20 13715/week @ 2024-03-27 15862/week @ 2024-04-03 15852/week @ 2024-04-10 15479/week @ 2024-04-17 14055/week @ 2024-04-24 12414/week @ 2024-05-01 9128/week @ 2024-05-08

54,389 downloads per month
Used in 191 crates (91 directly)

MIT/Apache

150KB
2.5K SLoC

fugit

fugit provides a comprehensive library of Duration and Instant for the handling of time in embedded systems, doing all it can at compile time.

This library is a heavily inspired of std::chrono's Duration from C++ which does all it can at compile time.

Aims

  • no_std library with goals of user-friendliness and performance first
    • All methods are const fn that can be (i.e. non-trait methods)
    • Use no traits, concrete types all the way for maximum const-ification
    • Operations are supported between different bases and backing storages instead of implementing custom traits
    • All constants needed for comparing or changing timebase are guaranteed compile time generated
  • Support for both u32 and u64 backing storage with efficient instruction lowering on MCUs
    • On Cortex-M3 and up: no soft-impls pulled in for both u32 and u64 except when changing base on u64
    • Comparisons on u32 and u64 do not use division, only changing base with all constants calculated at compile time
  • Selection of base happens at compile time
    • A common problem is that run time changing of base robs us of a lot of optimization opportunities, but since there are no traits and short-hands select the correct base at compile time.

Dependencies

~180KB