pub struct Datagram { /* private fields */ }Expand description
One end of a connected datagram pair.
Implementations§
Source§impl Datagram
impl Datagram
Sourcepub fn send(&self, payload: &[u8]) -> Result<usize>
pub fn send(&self, payload: &[u8]) -> Result<usize>
Send payload as one datagram.
§Errors
The other end is gone, or payload is longer than MAX_DATAGRAM.
Sourcepub fn recv(&self, buffer: &mut [u8]) -> Result<usize>
pub fn recv(&self, buffer: &mut [u8]) -> Result<usize>
The next datagram, into buffer: its length, cut to the buffer’s when it is longer, as a
datagram socket reads one. 0 when the other end is gone and says so (a Windows pipe
does; a Unix datagram socket may wait out its timeout instead).
§Errors
The read timeout passed before a datagram began (io::ErrorKind::WouldBlock or
io::ErrorKind::TimedOut), or the system’s error reading.
Sourcepub fn set_read_timeout(&self, timeout: Option<Duration>) -> Result<()>
pub fn set_read_timeout(&self, timeout: Option<Duration>) -> Result<()>
How long Self::recv waits for a datagram to begin; None waits for ever.
§Errors
The system’s error setting it.
Trait Implementations§
Source§impl AsFd for Datagram
Available on Unix only.
impl AsFd for Datagram
Available on Unix only.
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Borrows the file descriptor. Read more
Auto Trait Implementations§
impl Forget for Datagram
impl Freeze for Datagramwhere
I32NotAllOnes: Freeze,
impl Move for Datagram
impl RefUnwindSafe for Datagramwhere
I32NotAllOnes: RefUnwindSafe,
impl Send for Datagramwhere
I32NotAllOnes: Send,
impl Sync for Datagramwhere
I32NotAllOnes: Sync,
impl Unpin for Datagramwhere
I32NotAllOnes: Unpin,
impl UnsafeUnpin for Datagramwhere
I32NotAllOnes: UnsafeUnpin,
impl UnwindSafe for Datagramwhere
I32NotAllOnes: UnwindSafe,
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