Skip to main content

Socket

Enum Socket 

Source
pub enum Socket {
    Udp(Box<UdpSocket>),
    Tcp(Box<TcpSocket>),
    Raw(Box<RawSocket>),
    Unix(Box<UnixSocket>),
}
Expand description

Network socket abstraction.

Variants§

§

Udp(Box<UdpSocket>)

UDP socket.

§

Tcp(Box<TcpSocket>)

TCP socket.

§

Raw(Box<RawSocket>)

Raw IP socket.

§

Unix(Box<UnixSocket>)

Unix domain socket.

Trait Implementations§

Source§

impl Configurable for Socket

Source§

fn get_option_inner( &self, __enum_dispatch_arg_0: &mut GetSocketOption<'_>, ) -> NetResult<bool>

Get a socket option, returns true if the socket supports the option.

Source§

fn set_option_inner( &self, __enum_dispatch_arg_0: SetSocketOption<'_>, ) -> NetResult<bool>

Set a socket option, returns true if the socket supports the option.

Source§

fn get_option(&self, __enum_dispatch_arg_0: GetSocketOption<'_>) -> NetResult

Get a socket option. Dispatches to Configurable::get_option_inner.

Source§

fn set_option(&self, __enum_dispatch_arg_0: SetSocketOption<'_>) -> NetResult

Set a socket option. Dispatches to Configurable::set_option_inner.

Source§

impl From<Box<RawSocket>> for Socket

Source§

fn from(v: Box<RawSocket>) -> Socket

Converts to this type from the input type.
Source§

impl From<Box<TcpSocket>> for Socket

Source§

fn from(v: Box<TcpSocket>) -> Socket

Converts to this type from the input type.
Source§

impl From<Box<UdpSocket>> for Socket

Source§

fn from(v: Box<UdpSocket>) -> Socket

Converts to this type from the input type.
Source§

impl From<Box<UnixSocket>> for Socket

Source§

fn from(v: Box<UnixSocket>) -> Socket

Converts to this type from the input type.
Source§

impl From<TcpSocket> for Socket

Source§

fn from(socket: TcpSocket) -> Self

Converts to this type from the input type.
Source§

impl From<UdpSocket> for Socket

Source§

fn from(socket: UdpSocket) -> Self

Converts to this type from the input type.
Source§

impl From<UnixSocket> for Socket

Source§

fn from(socket: UnixSocket) -> Self

Converts to this type from the input type.
Source§

impl Pollable for Socket

Source§

fn poll(&self) -> IoEvents

Polls for I/O events.
Source§

unsafe fn register_shared( &self, sink: &mut dyn SharedRegistrationSink, events: IoEvents, )

Registers a shared readiness observer. Read more
Source§

unsafe fn register_exclusive( &self, sink: &mut dyn ExclusiveRegistrationSink, events: IoEvents, )

Registers a consumer that may sleep until readiness changes. Read more
Source§

impl SocketOps for Socket

Source§

fn bind(&self, __enum_dispatch_arg_0: SocketAddrEx) -> NetResult

Binds an unbound socket to the given address and port.

Source§

fn start_connect( &self, __enum_dispatch_arg_0: SocketAddrEx, ) -> NetResult<ConnectStatus>

Starts a connection without waiting for asynchronous completion.

Source§

fn connect_status(&self) -> NetResult<ConnectStatus>

Checks a previously started asynchronous connection.

Source§

fn listen(&self, __enum_dispatch_arg_0: usize) -> NetResult

Starts listening on the bound address and port.

Source§

fn is_listening(&self) -> bool

Returns whether this socket currently accepts incoming connections.

Source§

fn try_accept(&self) -> NetResult<Socket>

Attempts to accept one connection without parking the caller.

Source§

fn try_send( &self, __enum_dispatch_arg_0: impl Read + IoBuf, __enum_dispatch_arg_1: &mut SendOptions, ) -> NetResult<usize>

Attempts to send data without parking the caller.

Source§

fn try_recv( &self, __enum_dispatch_arg_0: impl Write + IoBufMut, __enum_dispatch_arg_1: &mut RecvOptions<'_>, ) -> NetResult<usize>

Attempts to receive data without parking the caller.

Source§

fn recv_available(&self) -> NetResult<usize>

Returns the number of bytes that can be read without blocking.

Source§

fn local_addr(&self) -> NetResult<SocketAddrEx>

Get the local endpoint of the socket.

Source§

fn peer_addr(&self) -> NetResult<SocketAddrEx>

Get the remote endpoint of the socket.

Source§

fn shutdown(&self, __enum_dispatch_arg_0: Shutdown) -> NetResult

Shutdown the socket, closing the connection.

Source§

fn send_wait_policy( &self, __enum_dispatch_arg_0: bool, ) -> NetResult<SocketWaitPolicy>

Returns the send wait policy without acquiring scheduler ownership.

Source§

fn recv_wait_policy( &self, __enum_dispatch_arg_0: bool, ) -> NetResult<SocketWaitPolicy>

Returns the receive wait policy without acquiring scheduler ownership.

Source§

impl TryInto<Box<RawSocket>> for Socket

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<Box<RawSocket>, <Self as TryInto<Box<RawSocket>>>::Error>

Performs the conversion.
Source§

impl TryInto<Box<TcpSocket>> for Socket

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<Box<TcpSocket>, <Self as TryInto<Box<TcpSocket>>>::Error>

Performs the conversion.
Source§

impl TryInto<Box<UdpSocket>> for Socket

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<Box<UdpSocket>, <Self as TryInto<Box<UdpSocket>>>::Error>

Performs the conversion.
Source§

impl TryInto<Box<UnixSocket>> for Socket

Source§

type Error = &'static str

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

fn try_into( self, ) -> Result<Box<UnixSocket>, <Self as TryInto<Box<UnixSocket>>>::Error>

Performs the conversion.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V