pub struct MioAdapter<MT>(/* private fields */);
Expand description
Adapt raw mio
type to mioco Evented
requirements.
See source of src/tcp.rs
for example of usage.
Implementations§
Source§impl MioAdapter<UnixSocket>
impl MioAdapter<UnixSocket>
Sourcepub fn stream() -> Result<UnixSocket>
pub fn stream() -> Result<UnixSocket>
Returns a new, unbound, Unix domain socket
Sourcepub fn connect<P: AsRef<Path> + ?Sized>(
self,
addr: &P,
) -> Result<(UnixStream, bool)>
pub fn connect<P: AsRef<Path> + ?Sized>( self, addr: &P, ) -> Result<(UnixStream, bool)>
Connect the socket to the specified address
Source§impl MioAdapter<UnixStream>
impl MioAdapter<UnixStream>
Sourcepub fn connect<P: AsRef<Path> + ?Sized>(path: &P) -> Result<UnixStream>
pub fn connect<P: AsRef<Path> + ?Sized>(path: &P) -> Result<UnixStream>
Connect UnixStream to path
Sourcepub fn try_read_recv_fd(
&mut self,
buf: &mut [u8],
) -> Result<Option<(usize, Option<RawFd>)>>
pub fn try_read_recv_fd( &mut self, buf: &mut [u8], ) -> Result<Option<(usize, Option<RawFd>)>>
Try reading data into a buffer.
This will not block.
Sourcepub fn read_recv_fd(&mut self, buf: &mut [u8]) -> Result<(usize, Option<RawFd>)>
pub fn read_recv_fd(&mut self, buf: &mut [u8]) -> Result<(usize, Option<RawFd>)>
Block on read.
Source§impl MioAdapter<TcpListener>
impl MioAdapter<TcpListener>
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Local address
Sourcepub fn take_socket_error(&self) -> Result<()>
pub fn take_socket_error(&self) -> Result<()>
TODO: document
Sourcepub fn try_clone(&self) -> Result<TcpListener>
pub fn try_clone(&self) -> Result<TcpListener>
Try cloning the listener descriptor.
Source§impl MioAdapter<TcpListener>
impl MioAdapter<TcpListener>
Sourcepub fn bind(addr: &SocketAddr) -> Result<Self>
pub fn bind(addr: &SocketAddr) -> Result<Self>
Bind to a port
Sourcepub fn from_listener(listener: TcpListener, addr: &SocketAddr) -> Result<Self>
pub fn from_listener(listener: TcpListener, addr: &SocketAddr) -> Result<Self>
Creates a new TcpListener from an instance of a std::net::TcpListener
type.
Source§impl MioAdapter<TcpStream>
impl MioAdapter<TcpStream>
Sourcepub fn connect(addr: &SocketAddr) -> Result<Self>
pub fn connect(addr: &SocketAddr) -> Result<Self>
Create a new TCP stream an issue a non-blocking connect to the specified address.
Sourcepub fn connect_stream(stream: TcpStream, addr: &SocketAddr) -> Result<Self>
pub fn connect_stream(stream: TcpStream, addr: &SocketAddr) -> Result<Self>
Creates a new TcpStream from the pending socket inside the given
std::net::TcpBuilder
, connecting it to the address specified.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Local address of connection.
Sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Peer address of connection.
Sourcepub fn set_nodelay(&self, nodelay: bool) -> Result<()>
pub fn set_nodelay(&self, nodelay: bool) -> Result<()>
Set no_delay
.
Sourcepub fn take_socket_error(&self) -> Result<()>
pub fn take_socket_error(&self) -> Result<()>
TODO: document
Source§impl MioAdapter<UdpSocket>
impl MioAdapter<UdpSocket>
Sourcepub fn bound(addr: &SocketAddr) -> Result<Self>
pub fn bound(addr: &SocketAddr) -> Result<Self>
Return a new bound UDP Socket.
Sourcepub fn bind(&self, addr: &SocketAddr) -> Result<()>
pub fn bind(&self, addr: &SocketAddr) -> Result<()>
Bind the unbound UDP Socket.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Local address of the Socket.
Sourcepub fn try_recv(
&mut self,
buf: &mut [u8],
) -> Result<Option<(usize, SocketAddr)>>
pub fn try_recv( &mut self, buf: &mut [u8], ) -> Result<Option<(usize, SocketAddr)>>
Try reading data into a buffer.
This will not block.
Sourcepub fn try_send(&self, buf: &[u8], target: &SocketAddr) -> Result<Option<usize>>
pub fn try_send(&self, buf: &[u8], target: &SocketAddr) -> Result<Option<usize>>
Try writing a data from the buffer.
This will not block.
Sourcepub fn set_broadcast(&self, on: bool) -> Result<()>
pub fn set_broadcast(&self, on: bool) -> Result<()>
Set broadcast flag.
Sourcepub fn set_multicast_loop(&self, on: bool) -> Result<()>
pub fn set_multicast_loop(&self, on: bool) -> Result<()>
Set multicast loop flag.
Sourcepub fn join_multicast(&self, multi: &IpAddr) -> Result<()>
pub fn join_multicast(&self, multi: &IpAddr) -> Result<()>
Join multicast.
Sourcepub fn leave_multicast(&self, multi: &IpAddr) -> Result<()>
pub fn leave_multicast(&self, multi: &IpAddr) -> Result<()>
Leave multicast.
Sourcepub fn set_multicast_time_to_live(&self, ttl: i32) -> Result<()>
pub fn set_multicast_time_to_live(&self, ttl: i32) -> Result<()>
Set multicast TTL.
Source§impl<MT> MioAdapter<MT>where
MT: Evented + 'static,
impl<MT> MioAdapter<MT>where
MT: Evented + 'static,
Source§impl<MT> MioAdapter<MT>
impl<MT> MioAdapter<MT>
Source§impl<MT> MioAdapter<MT>
impl<MT> MioAdapter<MT>
Source§impl<MT, O> MioAdapter<MT>
impl<MT, O> MioAdapter<MT>
Sourcepub fn try_accept(&self) -> Result<Option<MioAdapter<O>>>
pub fn try_accept(&self) -> Result<Option<MioAdapter<O>>>
Attempt to accept a pending connection.
This will not block.
Source§impl<MT, O> MioAdapter<MT>
impl<MT, O> MioAdapter<MT>
Sourcepub fn accept(&self) -> Result<MioAdapter<O>>
pub fn accept(&self) -> Result<MioAdapter<O>>
Block on accepting a connection.
Trait Implementations§
Source§impl<MT> AsRawFd for MioAdapter<MT>
impl<MT> AsRawFd for MioAdapter<MT>
Source§impl<MT> EventedImpl for MioAdapter<MT>where
MT: Evented + 'static,
impl<MT> EventedImpl for MioAdapter<MT>where
MT: Evented + 'static,
Source§impl<MT> FromRawFd for MioAdapter<MT>
impl<MT> FromRawFd for MioAdapter<MT>
Source§unsafe fn from_raw_fd(fd: RawFd) -> Self
unsafe fn from_raw_fd(fd: RawFd) -> Self
Self
from the given raw file
descriptor. Read moreSource§impl<MT> Read for MioAdapter<MT>
impl<MT> Read for MioAdapter<MT>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreSource§impl<MT> Write for MioAdapter<MT>
impl<MT> Write for MioAdapter<MT>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)