Struct ublox_sockets::udp::UdpSocket
source · [−]Expand description
A User Datagram Protocol socket.
A UDP socket is bound to a specific endpoint, and owns transmit and receive packet buffers.
Implementations
sourceimpl<const TIMER_HZ: u32, const L: usize> UdpSocket<TIMER_HZ, L>
impl<const TIMER_HZ: u32, const L: usize> UdpSocket<TIMER_HZ, L>
sourcepub fn new(socket_id: u8) -> UdpSocket<TIMER_HZ, L>
pub fn new(socket_id: u8) -> UdpSocket<TIMER_HZ, L>
Create an UDP socket with the given buffers.
sourcepub fn handle(&self) -> SocketHandle
pub fn handle(&self) -> SocketHandle
Return the socket handle.
pub fn update_handle(&mut self, handle: SocketHandle)
sourcepub fn endpoint(&self) -> Option<SocketAddr>
pub fn endpoint(&self) -> Option<SocketAddr>
Return the bound endpoint.
pub fn set_state(&mut self, state: State)
pub fn should_update_available_data(&mut self, ts: Instant<TIMER_HZ>) -> bool
pub fn recycle(&self, ts: Instant<TIMER_HZ>) -> bool
pub fn closed_by_remote(&mut self, ts: Instant<TIMER_HZ>)
sourcepub fn set_available_data(&mut self, available_data: usize)
pub fn set_available_data(&mut self, available_data: usize)
Set available data.
sourcepub fn get_available_data(&self) -> usize
pub fn get_available_data(&self) -> usize
Get the number of bytes available to ingress.
pub fn rx_window(&self) -> usize
sourcepub fn bind<T: Into<SocketAddr>>(&mut self, endpoint: T) -> Result<(), Error>
pub fn bind<T: Into<SocketAddr>>(&mut self, endpoint: T) -> Result<(), Error>
Bind the socket to the given endpoint.
This function returns Err(Error::Illegal)
if the socket was open
(see is_open), and Err(Error::Unaddressable)
if the port in the given endpoint is zero.
sourcepub fn recv<'b, F, R>(&'b mut self, f: F) -> Result<R, Error>where
F: FnOnce(&'b mut [u8]) -> (usize, R),
pub fn recv<'b, F, R>(&'b mut self, f: F) -> Result<R, Error>where
F: FnOnce(&'b mut [u8]) -> (usize, R),
Dequeue a packet received from a remote endpoint, and return the endpoint as well as a pointer to the payload.
This function returns Err(Error::Exhausted)
if the receive buffer is empty.
sourcepub fn recv_slice(&mut self, data: &mut [u8]) -> Result<usize, Error>
pub fn recv_slice(&mut self, data: &mut [u8]) -> Result<usize, Error>
Dequeue a packet received from a remote endpoint, copy the payload into the given slice, and return the amount of octets copied as well as the endpoint.
See also recv.
pub fn rx_enqueue_slice(&mut self, data: &[u8]) -> usize
sourcepub fn peek(&mut self, size: usize) -> Result<&[u8], Error>
pub fn peek(&mut self, size: usize) -> Result<&[u8], Error>
Peek at a packet received from a remote endpoint, and return the endpoint as well as a pointer to the payload without removing the packet from the receive buffer. This function otherwise behaves identically to recv.
It returns Err(Error::Exhausted)
if the receive buffer is empty.
sourcepub fn peek_slice(&mut self, data: &mut [u8]) -> Result<usize, Error>
pub fn peek_slice(&mut self, data: &mut [u8]) -> Result<usize, Error>
Peek at a packet received from a remote endpoint, copy the payload into the given slice, and return the amount of octets copied as well as the endpoint without removing the packet from the receive buffer. This function otherwise behaves identically to recv_slice.
See also peek.