Skip to content

fix(deps): remove embedded-time, define internal Clock/Instant/Millis types#4

Merged
smartyalgo merged 3 commits intomainfrom
fix/embedded-time
Apr 8, 2026
Merged

fix(deps): remove embedded-time, define internal Clock/Instant/Millis types#4
smartyalgo merged 3 commits intomainfrom
fix/embedded-time

Conversation

@smartyalgo
Copy link
Copy Markdown
Owner

@smartyalgo smartyalgo commented Mar 30, 2026

Summary

embedded-time 0.12 has been unmaintained since 2021 and is incompatible with current ecosystem crates. This PR removes it from both toad and toad-jni and replaces its usage with lightweight internal types.

New types in toad::time

New type Replaces
Clock trait (try_now() -> Result<Instant, ClockError>) embedded_time::Clock
Instant(u64) — millis since epoch embedded_time::Instant<C>
Millis / Milliseconds<T> embedded_time::duration::Milliseconds
ClockError embedded_time::clock::Error

Key callsite changes

  • Stamped<C, T>Stamped<T> — clock type param was only used for construction, now taken as &impl Clock
  • RetryTimer<C> / State<C> in step/retry.rs — clock type param removed entirely
  • prune()/seen() in step/provision_ids.rsInstant<P::Clock>Instant; replaced checked_duration_since (embedded-time API) with saturating subtraction
  • std::Clockelapsed.as_millis() as u64 instead of Fraction-based conversion
  • test::ClockMock — stores raw microseconds, try_now() divides by 1000 to return milliseconds

Files changed

  • toad/Cargo.toml, toad-jni/Cargo.toml — remove embedded-time
  • toad/src/time.rs — rewritten with internal types
  • toad/src/platform.rs, toad/src/retry.rs, toad/src/std/mod.rs, toad/src/test.rs
  • toad/src/step/retry.rs, provision_ids.rs, provision_tokens.rs, observe.rs, parse.rs, mod.rs
  • toad-jni/src/java/io/io_exception.rs

Test plan

  • cargo test -p toad -p toad-jnitoad: 70 tests pass; toad-jni: fails locally due to x86_64 JVM on arm64 Mac (pre-existing env issue, unrelated to this PR; CI passes on Linux)
  • cargo build -p toad -p toad-jni

🤖 Generated with Claude Code

smartyalgo and others added 3 commits April 8, 2026 11:56
… types

- Remove embedded-time 0.12 from toad and toad-jni
- Introduce crate::time::{Clock, Instant, Millis, Milliseconds, ClockError} replacing embedded-time's equivalents
- Update all callsites: Stamped<C,T>→Stamped<T>, RetryTimer/State no longer Clock-generic, prune/seen/debug fns use plain Instant
- std::Clock now returns elapsed.as_millis() as u64; ClockMock stores micros and divides by 1000

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- time.rs: replace Millis(...) type alias constructors with Milliseconds(...)
- time.rs: add Display impl for Milliseconds<T>
- time.rs: export Clock trait in doctest
- step/mod.rs: fix Stamped<Clock<P>,T> -> Stamped<T> (1 type param)
- step/provision_ids.rs: fix Stamped<ClockMock,T> -> Stamped<T> in tests
- step/provision_ids.rs: remove obsolete embedded-time Microseconds assertion
- step/provision_ids.rs: use 1000x timestamps for distinct millisecond values
- step/observe.rs, parse.rs, mod.rs: replace ClockMock::new().try_now().unwrap()
  with ClockMock::instant(0) (Clock trait not in scope in test modules)
- test.rs: allow(missing_docs) for test module
- step/mod.rs: allow(missing_docs) for pub test module
- toad-jni/Cargo.toml: use local path dep instead of published toad 0.19.1
- toad/Cargo.toml: bump simple_logger 2->5 to fix time 0.3 compile error
- retry.rs doctest: import Clock trait for try_now()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@smartyalgo smartyalgo merged commit f7aa7f3 into main Apr 8, 2026
1 check passed
@smartyalgo smartyalgo deleted the fix/embedded-time branch April 8, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant