sntpc-net-std 1.2.0

std socket wrapper for sntpc library
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented2 out of 2 items with examples
  • Size
  • Source code size: 20.36 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 302.92 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: 19s 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-net-std

Standard library UDP socket adapter for the sntpc SNTP client library.

Design Goal

This crate provides a thin wrapper around std::net::UdpSocket that implements the NtpUdpSocket trait from sntpc. This separation allows:

  • Independent versioning: Update sntpc-net-std without touching core sntpc
  • Minimal dependencies: Only depends on std and sntpc core
  • Flexibility: Users can choose their network stack independently

Usage

Add this to your Cargo.toml:

[dependencies]
sntpc = "0.10"
sntpc-net-std = "1"

Example

use sntpc::{sync::get_time, NtpContext, StdTimestampGen};
use sntpc_net_std::UdpSocketWrapper;
use std::net::UdpSocket;

let socket = UdpSocket::bind("0.0.0.0:0").expect("Unable to create UDP socket");
let socket = UdpSocketWrapper::new(socket);
let context = NtpContext::new(StdTimestampGen::default ());

// Use with sntpc functions

For complete examples, see the sntpc examples.

License