sntpc-time-embassy
NtpTimestampGenerator implementation backed by embassy-time for the sntpc SNTP client library.
Design Goal
This crate provides an [EmbassyTimestampGenerator] that implements the NtpTimestampGenerator trait from sntpc using the Embassy async runtime's monotonic clock. This separation allows:
- Independent versioning: Update
embassy-timewithout requiringsntpccore updates - Version flexibility: Works with
embassy-time0.5.x (>=0.5, <0.6) - Embedded focus: Minimal dependencies suitable for
no_stdembedded systems - Clean separation: Core SNTP protocol logic remains independent of the async runtime
Important
EmbassyTimestampGenerator provides monotonic timestamps based on embassy_time::Instant, not wall-clock time. This is sufficient for SNTP request/response delay calculations, where only the relative elapsed time between request and response matters. The actual wall-clock offset is computed by the sntpc library using the server's timestamps.
Usage
Add this to your Cargo.toml:
[]
= { = "0.10", = false }
= "0.5"
= ">=0.5,<0.6"
Example
use ;
use EmbassyTimestampGenerator;
// Create an NtpContext with the Embassy timestamp generator
let ntp_context = new;
// Use with an Embassy UDP socket adapter
let result = get_time.await;
For complete examples, see the sntpc examples.
Compatibility
- sntpc: 0.10.x
- embassy-time: 0.5.x (any version >= 0.5, < 0.6)
- no_std: Fully supported