t2t-core 0.1.1

time values: points on the wall and monotonic clocks, counter readings, and the spans between them.
Documentation

t2t-core

The values of t2t: points on the wall, monotonic, boot and atomic timelines, a hardware counter's readings, the spans between them, the rate that turns ticks into nanoseconds, a UTC calendar, and a value stamped with the time it was captured. Each is one i64 or a few, no_std and allocating nothing, and each has a spelling it writes and reads back. The clocks that read them are in t2t-clock, and t2t holds both.

Install

cargo add t2t-core

t2t-core builds with Rust 1.98 or later, with or without std.

Quick Start

use t2t_core::{ParseTimedeltaError, Timed, Timedelta, Timestamp};

fn main() -> Result<(), ParseTimedeltaError> {
    let stale: Timedelta = "1s".parse()?;
    let captured = Timestamp::from_secs(1_700_000_000);
    let sample = Timed::new(captured, 101_u64);

    assert!(sample.elapsed(captured + Timedelta::from_millis(1_500)) > stale, "stale by now");
    Ok(())
}

Features

Feature Adds
std SystemTime conversions
serde every value's spelling, and the serde modules for counts in a named unit
schemars JsonSchema for every value with a spelling; turns serde on
zerocopy the zerocopy traits each type can honour, native-endian
chrono-04 conversions to and from chrono 0.4's DateTime and TimeDelta
jiff-02 conversions to and from jiff 0.2's Timestamp and SignedDuration
time-03 conversions to and from time 0.3's OffsetDateTime and Duration

None is on by default: cargo add t2t-core --features serde.

Documentation

License

Either the MIT License or the Apache License, Version 2.0, at your option.