pub struct UdpSocketWrapper { /* private fields */ }Expand description
A wrapper around std::net::UdpSocket that implements NtpUdpSocket.
This type allows standard library UDP sockets to be used with the sntpc library
for making SNTP requests. It provides a simple synchronous interface suitable for
blocking I/O operations.
§Example
use sntpc_net_std::UdpSocketWrapper;
use std::net::UdpSocket;
let socket = UdpSocket::bind("0.0.0.0:0").expect("Failed to bind socket");
let wrapper = UdpSocketWrapper::new(socket);
// Use wrapper with sntpc functionsImplementations§
Source§impl UdpSocketWrapper
impl UdpSocketWrapper
Sourcepub fn new(socket: UdpSocket) -> Self
pub fn new(socket: UdpSocket) -> Self
Creates a new UdpSocketWrapper from a std::net::UdpSocket.
§Arguments
socket- A UDP socket to wrap
§Example
use sntpc_net_std::UdpSocketWrapper;
use std::net::UdpSocket;
let socket = UdpSocket::bind("0.0.0.0:0").expect("Failed to bind");
let wrapper = UdpSocketWrapper::new(socket);Trait Implementations§
Source§impl From<UdpSocket> for UdpSocketWrapper
impl From<UdpSocket> for UdpSocketWrapper
Source§fn from(socket: UdpSocket) -> Self
fn from(socket: UdpSocket) -> Self
Converts a std::net::UdpSocket into a UdpSocketWrapper.
This provides a convenient way to create a wrapper using .into() or from().
§Example
use sntpc_net_std::UdpSocketWrapper;
use std::net::UdpSocket;
let socket = UdpSocket::bind("0.0.0.0:0").expect("Failed to bind");
let wrapper: UdpSocketWrapper = socket.into();Source§impl NtpUdpSocket for UdpSocketWrapper
impl NtpUdpSocket for UdpSocketWrapper
Auto Trait Implementations§
impl Freeze for UdpSocketWrapper
impl RefUnwindSafe for UdpSocketWrapper
impl Send for UdpSocketWrapper
impl Sync for UdpSocketWrapper
impl Unpin for UdpSocketWrapper
impl UnwindSafe for UdpSocketWrapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more