4 releases
0.1.3 | Dec 10, 2024 |
---|---|
0.1.2 | Dec 6, 2024 |
0.1.1 | Dec 4, 2024 |
0.1.0 | Dec 4, 2024 |
#100 in Date and time
485 downloads per month
150KB
3K
SLoC
typus_fugit
typus_fugit
provides a comprehensive library ofDuration
andInstant
for the handling of time in embedded systems, using compile-time types to represent values.
This library began as a fork of fugit
, which is, in turn, a heavily inspired of std::chrono
's Duration
from C++ which does all it can at compile time.
The decision to fork was due to the desire to replace const-generics values represented in the type system. This provides:
- Specification of legal values within the type system
- Evaluation of values within the type system
- Erasure of machine representation of values until needed at execution time
Initial implementation uses typenum
for type-level values and evaluation. There is an intent to migrate to type_eval
when it's ready.
Should I use typus_fugit
over fugit
?
I cannot escape the fact that forking fugit
fractures the ecosystem. Please do not use, or depend, on this crate, unless the topics of values at the type-level is of interest to you. This crate is, in significant part, motivated by assessing the reality of what a migration from const-generics to type-vals would look like.
Aims
- Try to stay in sync with
fugit
- If users wish to switch between the two, the process should be low-friction and relatively reliable
- If
fugit
decides to migrate to types instead of consts, the result should not look very different totypus_fugit
no_std
library with goals of user-friendliness and performance first- Priority placed on type-level evaluation
- When type-level evaluation isn't available, use
const fn
where the possible. - All timebase operations performed using type-level evaluation
- Support for both
u32
andu64
backing storage with efficient instruction lowering on MCUs- On Cortex-M3 and up: no soft-impls pulled in for both
u32
andu64
except when changing base onu64
- Comparisons on
u32
andu64
do not use division, only changing base with all constants calculated at compile time
- On Cortex-M3 and up: no soft-impls pulled in for both
- Selection of base happens at compile time, within the type-system.
- A common problem is that run time changing of base robs us of a lot of optimization opportunities, but since types are used here, bases are evaluated at compile time.
Name
The original fugit
name, as I understand it, comes from the latin phrase "tempus fugit", i.e. "time flies".
typus_fugit
is a pun coming from said understanding.
Dependencies
~225–465KB
~11K SLoC