ready-active-safe 0.1.3

Lifecycle engine for externally driven systems
Documentation
# Instant

*Requires feature `time`.*

A monotonic instant represented as nanoseconds since an arbitrary origin.

Small, `Copy`, `no_std`-friendly. Suitable for deadlines, timeouts,
elapsed-time calculations, and deterministic replay with a virtual clock.

## Construction

```rust
use ready_active_safe::time::Instant;

let t = Instant::from_nanos(1_000_000_000);
assert_eq!(t.as_nanos(), 1_000_000_000);
```

## `checked_duration_since`

Returns the duration between two instants, if `self >= earlier`.

```rust
use ready_active_safe::time::Instant;
use std::time::Duration;

let a = Instant::from_nanos(1_000_000_000);
let b = Instant::from_nanos(3_000_000_000);

assert_eq!(b.checked_duration_since(a), Some(Duration::from_secs(2)));
assert_eq!(a.checked_duration_since(b), None); // a < b
```

## `checked_add` / `checked_sub`

```rust
use ready_active_safe::time::Instant;
use std::time::Duration;

let t = Instant::from_nanos(1_000_000_000);

let later = t.checked_add(Duration::from_secs(1));
assert_eq!(later.map(|i| i.as_nanos()), Some(2_000_000_000));

let earlier = t.checked_sub(Duration::from_millis(500));
assert_eq!(earlier.map(|i| i.as_nanos()), Some(500_000_000));
```

## Edge Cases

Overflow returns `None`:

```rust
use ready_active_safe::time::Instant;
use std::time::Duration;

let max = Instant::from_nanos(u64::MAX);
assert!(max.checked_add(Duration::from_nanos(1)).is_none());
```

Underflow returns `None`:

```rust
use ready_active_safe::time::Instant;
use std::time::Duration;

let zero = Instant::from_nanos(0);
assert!(zero.checked_sub(Duration::from_nanos(1)).is_none());
```

## Ordering

Instants are `Ord`, so they can be compared and sorted:

```rust
use ready_active_safe::time::Instant;

let a = Instant::from_nanos(100);
let b = Instant::from_nanos(200);
assert!(a < b);
```

## See Also

- [`Clock`]clock.md — returns `Instant` values
- [`Deadline`]deadline.md — wraps an `Instant` as an expiration point