Standard library UDP socket adapter for the sntpc SNTP client library.
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-stdwithout touching coresntpc - Minimal dependencies: Only depends on
stdandsntpccore - Flexibility: Users can choose their network stack independently
Add this to your Cargo.toml:
[dependencies]
sntpc = "0.9"
sntpc-net-std = "1"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 functionsFor complete examples, see the sntpc examples.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this codebase by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.