sntpc-time-embassy 0.5.0

Embassy timestamp generator for sntpc library
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 12.27 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 169.79 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • vpetrigo/sntpc
    71 29 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vpetrigo

GitHub Actions Workflow Status Crates.io docs.rs

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-time without requiring sntpc core updates
  • Version flexibility: Works with embassy-time 0.5.x (>=0.5, <0.6)
  • Embedded focus: Minimal dependencies suitable for no_std embedded 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:

[dependencies]
sntpc = { version = "0.10", default-features = false }
sntpc-time-embassy = "0.5"
embassy-time = ">=0.5,<0.6"

Example

use sntpc::{get_time, NtpContext};
use sntpc_time_embassy::EmbassyTimestampGenerator;

// Create an NtpContext with the Embassy timestamp generator
let ntp_context = NtpContext::new(EmbassyTimestampGenerator::default());

// Use with an Embassy UDP socket adapter
let result = get_time(server_addr, &socket, ntp_context).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

License