pub struct DatagramReader(/* private fields */);
Expand description
Implementations§
Source§impl DatagramReader
impl DatagramReader
Sourcepub fn poll_recv(&self, cx: &mut Context<'_>) -> Poll<Result<Bytes, Error>>
pub fn poll_recv(&self, cx: &mut Context<'_>) -> Poll<Result<Bytes, Error>>
This is the internal implementation of the DatagramReader::recv
method.
If the datagram is not ready, and the connection is active,
the method will return Poll::Pending
and set the waker for waking up the task when the datagram is received.
Note that only the waker set by the last call may be awakened
While there has a datagram frame received but unread,
this method will return Poll::Ready
with the received datagram frame as Ok
.
If the connection is closing or already closed,
this method will return Poll::Ready
with an error as Err
.
Sourcepub fn recv(&mut self) -> RecvDatagram<'_>
pub fn recv(&mut self) -> RecvDatagram<'_>
Receive a datagram frame from peer.
This method is asynchronous and returns a future that resolves to the received datagram.
pub async fn recv(&self) -> io::Result<Bytes>
The future will yield the received datagram as Ok
.
If the connection is closing or already closed, the future will yield an error as Err
.
The future is Cancel Safe.
Sourcepub fn read<'b>(&'b mut self, buf: &'b mut [u8]) -> ReadIntoSlice<'b>
pub fn read<'b>(&'b mut self, buf: &'b mut [u8]) -> ReadIntoSlice<'b>
Reads the received datagram frame into a mutable slice.
This method is asynchronous and returns a future that resolves to the number of bytes read.
pub async fn read(&self, buf: & mut [u8]) -> io::Result<usize>
The future will yield the size of bytes read from the received datagram as Ok
.
If the buffer is not large enough to hold the received data, the received data will be truncated.
If the connection is closing or already closed, the future will yield an error as Err
.
Sourcepub fn read_buf<'b, B>(&'b mut self, buf: &'b mut B) -> ReadIntoBuf<'b, B>where
B: BufMut,
pub fn read_buf<'b, B>(&'b mut self, buf: &'b mut B) -> ReadIntoBuf<'b, B>where
B: BufMut,
Reads the received datagram frame into a mutable reference to bytes::BufMut
.
This method is asynchronous and returns a future that resolves to the number of bytes read.
pub async fn read_buf(&self, buf: & mut [u8]) -> io::Result<usize>
The future will yield the size of bytes read from the received datagram as Ok
.
If the buffer is not large enough to hold the received data, the behavior is defined by the bytes::BufMut::put
implementation.
If the connection is closing or already closed, the future will yield an error as Err
.
Trait Implementations§
Source§impl Clone for DatagramReader
impl Clone for DatagramReader
Source§fn clone(&self) -> DatagramReader
fn clone(&self) -> DatagramReader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more