Skip to main content

Datagram

Struct Datagram 

Source
pub struct Datagram { /* private fields */ }
Expand description

One end of a connected datagram pair.

Implementations§

Source§

impl Datagram

Source

pub fn pair() -> Result<(Self, Self)>

Two connected ends, both in this process.

§Errors

The system’s error making the pair.

Source

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.

Source

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.

Source

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.

Source

pub fn try_clone(&self) -> Result<Self>

A second handle on this end, for a thread that sends while another reads.

§Errors

The system’s error duplicating it.

Trait Implementations§

Source§

impl AsFd for Datagram

Available on Unix only.
Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl AsRawFd for Datagram

Available on Unix only.
Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Debug for Datagram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<OwnedFd> for Datagram

Available on Unix only.

The end a process inherited by its descriptor.

Source§

fn from(fd: OwnedFd) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.