fn udp_reader(&mut self, sn: Sn) -> Result<UdpReader<Self>, Error<Self::Error>>
    where
        Self: Sized,
    {
        debug_assert_eq!(self.sn_sr(sn)?, Ok(SocketStatus::Udp));

        let rsr: u16 = match self.sn_rx_rsr(sn)?.checked_sub(UdpHeader::LEN) {
            Some(rsr) => rsr,
            // nothing to recieve
            None => return Err(Error::WouldBlock),
        };

        let sn_rx_rd: u16 = self.sn_rx_rd(sn)?;
        let mut header: [u8; UdpHeader::LEN_USIZE] = [0; UdpHeader::LEN_USIZE];
        self.sn_rx_buf(sn, sn_rx_rd, &mut header)?;
        let header: UdpHeader = UdpHeader::deser(header);

        // limit to the length of the first datagram if we have more than a
        // single datagram enqueued
        let rsr_or_datagram_len: u16 = min(header.len, rsr);

        let head_ptr: u16 = sn_rx_rd.wrapping_add(UdpHeader::LEN);

        Ok(UdpReader {
            inner: TcpReader {
                w5500: self,
                sn,
                head_ptr,
                tail_ptr: head_ptr.wrapping_add(rsr_or_datagram_len),
                ptr: head_ptr,
            },
            header,
        })
    }
/// Create a UDP reader.
///
/// This returns a [`UdpReader`] structure, which contains functions to
/// stream data from the W5500 socket buffers incrementally.
///
/// This will return [`Error::WouldBlock`] if there is no data to read.
///
/// # Errors
///
/// This method can only return:
///
/// * [`Error::Other`]
/// * [`Error::WouldBlock`]
///
/// # Example
///
/// See [`UdpReader`].
Create a UDP reader.
This returns a [`UdpReader`] structure, which contains functions to
stream data from the W5500 socket buffers incrementally.

This will return [`Error::WouldBlock`] if there is no data to read.
Create a UDP reader . This returns a [ ` UdpReader ` ] structure which contains functions to stream data from the W5500 socket buffers incrementally . This will return [ ` Error :: WouldBlock ` ] if there is no data to read .
fn udp_reader(&mut self, sn: Sn) -> Result<UdpReader<Self>, Error<Self::Error>>
    where
        Self: Sized,
    {
        debug_assert_eq!(self.sn_sr(sn)?, Ok(SocketStatus::Udp));
        let rsr: u16 = match self.sn_rx_rsr(sn)?.checked_sub(UdpHeader::LEN) {
            Some(rsr) => rsr,
            // nothing to recieve
            None => return Err(Error::WouldBlock),
        };
        let sn_rx_rd: u16 = self.sn_rx_rd(sn)?;
        let mut header: [u8; UdpHeader::LEN_USIZE] = [0; UdpHeader::LEN_USIZE];
        self.sn_rx_buf(sn, sn_rx_rd, &mut header)?;
        let header: UdpHeader = UdpHeader::deser(header);
        // limit to the length of the first datagram if we have more than a
        // single datagram enqueued
        let rsr_or_datagram_len: u16 = min(header.len, rsr);
        let head_ptr: u16 = sn_rx_rd.wrapping_add(UdpHeader::LEN);
        Ok(UdpReader {
            inner: TcpReader {
                w5500: self,
                sn,
                head_ptr,
                tail_ptr: head_ptr.wrapping_add(rsr_or_datagram_len),
                ptr: head_ptr,
            },
            header,
        })
    }
fn udp_reader ( & mut self , sn : Sn ) -> Result < UdpReader < Self > , Error < Self :: Error > > where Self : Sized , { debug_assert_eq ! ( self sn_sr ( sn ) Ok ( SocketStatus Udp ) ) ; let rsr : u16 = match self . sn_rx_rsr ( sn ) ? . checked_sub ( UdpHeader :: LEN ) { Some ( rsr ) => rsr , // nothing to recieve None => return Err ( Error :: WouldBlock ) , } ; let sn_rx_rd : u16 = self . sn_rx_rd ( sn ) ? ; let mut header : [ u8 ; UdpHeader :: LEN_USIZE ] = [ 0 ; UdpHeader :: LEN_USIZE ] ; self . sn_rx_buf ( sn , sn_rx_rd , & mut header ) ? ; let header : UdpHeader = UdpHeader :: deser ( header ) ; // limit to the length of the first datagram if we have more than a // single datagram enqueued let rsr_or_datagram_len : u16 = min ( header . len , rsr ) ; let head_ptr : u16 = sn_rx_rd . wrapping_add ( UdpHeader :: LEN ) ; Ok ( UdpReader { inner : TcpReader { w5500 : self , sn , head_ptr , tail_ptr : head_ptr . wrapping_add ( rsr_or_datagram_len ) , ptr : head_ptr , } , header , } ) }
Create a UDP reader.
Create a UDP reader .
&mut self
sn
Sn
&mut self
sn
Sn
errors
This method can only return.

[`Error::Other`]
[`Error::WouldBlock`]
This method can only return . [ ` Error :: Other ` ] [ ` Error :: WouldBlock ` ]
example
None