Skip to main content

Socket

Trait Socket 

Source
pub trait Socket: Source {
    type Error;

    const MAX_IOVECS: usize;
Show 21 methods // Required methods fn socket(domain: c_int, kind: c_int) -> Result<OwnedFd, Self::Error>; fn pair() -> Result<(OwnedFd, OwnedFd), Error>; // Provided methods fn datagram<E: From<Errno>>(domain: Domain) -> Result<OwnedFd, E> { ... } fn try_open<E: From<Errno>>( domain: c_int, kind: c_int, protocol: c_int, ) -> Result<OwnedFd, E> { ... } fn listen<E: From<Errno>>( file: BorrowedFd<'_>, backlog: c_int, ) -> Result<(), E> { ... } fn shutdown<E: From<Errno>>(file: BorrowedFd<'_>, how: How) -> Result<(), E> { ... } fn peer_addr<E: From<Errno>>( file: BorrowedFd<'_>, address: &mut Storage, ) -> Result<(), E> { ... } fn reset_on_close<E: From<Errno>>(file: BorrowedFd<'_>) -> Result<(), E> { ... } fn kind<E: From<Errno>>(file: BorrowedFd<'_>) -> Result<Type, E> { ... } fn is_listening<E: From<Errno>>(file: BorrowedFd<'_>) -> Result<bool, E> { ... } fn set_reuse<E: From<Errno>>( file: BorrowedFd<'_>, reuse: Reuse, ) -> Result<(), E> { ... } fn send_quiet<'a, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], ) -> Result<&'a [u8], E> { ... } fn send_now<'a, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], ) -> Result<&'a [u8], E> { ... } fn get_option<const OPTION: c_int, E: From<Errno>>( file: BorrowedFd<'_>, ) -> Result<c_int, E> { ... } fn set_option<E: From<Errno>>( file: BorrowedFd<'_>, level: c_int, option: c_int, value: &c_int, ) -> Result<(), E> { ... } fn send<'a, const FLAGS: c_int, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], ) -> Result<&'a [u8], E> { ... } fn recv<'a, const FLAGS: c_int, E: From<Errno>>( file: BorrowedFd<'_>, output: &'a mut [u8], ) -> Result<&'a mut [u8], E> { ... } fn recv_now<'a, E: From<Errno>>( file: BorrowedFd<'_>, output: &'a mut [u8], ) -> Result<&'a mut [u8], E> { ... } fn send_to<'a, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], address: Addr<'_>, ) -> Result<&'a [u8], E> { ... } fn recv_from<'a, E: From<Errno>>( file: BorrowedFd<'_>, output: &'a mut [u8], address: &mut Storage, ) -> Result<&'a mut [u8], E> { ... } fn try_pair<E: From<Errno>>(kind: c_int) -> Result<(OwnedFd, OwnedFd), E> { ... }
}
Expand description

Native socket creation and asynchronous tuning capability.

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn socket(domain: c_int, kind: c_int) -> Result<OwnedFd, Self::Error>

Source

fn pair() -> Result<(OwnedFd, OwnedFd), Error>

Creates exclusively owned local socket endpoints.

Provided Methods§

Source

fn datagram<E: From<Errno>>(domain: Domain) -> Result<OwnedFd, E>

Creates one datagram descriptor without changing its descriptor flags.

Source

fn try_open<E: From<Errno>>( domain: c_int, kind: c_int, protocol: c_int, ) -> Result<OwnedFd, E>

Source

fn listen<E: From<Errno>>(file: BorrowedFd<'_>, backlog: c_int) -> Result<(), E>

Source

fn shutdown<E: From<Errno>>(file: BorrowedFd<'_>, how: How) -> Result<(), E>

Half-closes one socket in the requested direction.

Source

fn peer_addr<E: From<Errno>>( file: BorrowedFd<'_>, address: &mut Storage, ) -> Result<(), E>

Observes the connected peer into caller-owned native address storage.

Source

fn reset_on_close<E: From<Errno>>(file: BorrowedFd<'_>) -> Result<(), E>

Makes closing this exclusively owned connection send a reset.

Source

fn kind<E: From<Errno>>(file: BorrowedFd<'_>) -> Result<Type, E>

Observes the socket type of one adopted descriptor.

Source

fn is_listening<E: From<Errno>>(file: BorrowedFd<'_>) -> Result<bool, E>

Whether one adopted descriptor is already listening.

Source

fn set_reuse<E: From<Errno>>( file: BorrowedFd<'_>, reuse: Reuse, ) -> Result<(), E>

Admits the requested address reuse on one socket.

Source

fn send_quiet<'a, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], ) -> Result<&'a [u8], E>

Sends one byte string without raising the termination signal.

Source

fn send_now<'a, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], ) -> Result<&'a [u8], E>

Sends without waiting or raising the termination signal.

Source

fn get_option<const OPTION: c_int, E: From<Errno>>( file: BorrowedFd<'_>, ) -> Result<c_int, E>

Source

fn set_option<E: From<Errno>>( file: BorrowedFd<'_>, level: c_int, option: c_int, value: &c_int, ) -> Result<(), E>

Source

fn send<'a, const FLAGS: c_int, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], ) -> Result<&'a [u8], E>

Source

fn recv<'a, const FLAGS: c_int, E: From<Errno>>( file: BorrowedFd<'_>, output: &'a mut [u8], ) -> Result<&'a mut [u8], E>

Source

fn recv_now<'a, E: From<Errno>>( file: BorrowedFd<'_>, output: &'a mut [u8], ) -> Result<&'a mut [u8], E>

Source

fn send_to<'a, E: From<Errno>>( file: BorrowedFd<'_>, input: &'a [u8], address: Addr<'_>, ) -> Result<&'a [u8], E>

Sends one datagram to the retained native destination.

Source

fn recv_from<'a, E: From<Errno>>( file: BorrowedFd<'_>, output: &'a mut [u8], address: &mut Storage, ) -> Result<&'a mut [u8], E>

Receives one datagram and its source into caller-owned storage.

Source

fn try_pair<E: From<Errno>>(kind: c_int) -> Result<(OwnedFd, OwnedFd), E>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§