Struct MioAdapter

Source
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<UnixListener>

Source

pub fn bind<P: AsRef<Path> + ?Sized>(addr: &P) -> Result<Self>

Bind to a port

Source

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

Try cloning the socket descriptor.

Source§

impl MioAdapter<UnixSocket>

Source

pub fn stream() -> Result<UnixSocket>

Returns a new, unbound, Unix domain socket

Source

pub fn connect<P: AsRef<Path> + ?Sized>( self, addr: &P, ) -> Result<(UnixStream, bool)>

Connect the socket to the specified address

Source

pub fn bind<P: AsRef<Path> + ?Sized>(&self, addr: &P) -> Result<()>

Bind the socket to the specified address

Source

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

Clone

Source§

impl MioAdapter<UnixStream>

Source

pub fn connect<P: AsRef<Path> + ?Sized>(path: &P) -> Result<UnixStream>

Connect UnixStream to path

Source

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

Clone

Source

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.

Source

pub fn read_recv_fd(&mut self, buf: &mut [u8]) -> Result<(usize, Option<RawFd>)>

Block on read.

Source

pub fn try_write_send_fd(&self, buf: &[u8], fd: RawFd) -> Result<Option<usize>>

Try writing a data from the buffer.

This will not block.

Source

pub fn write_send_fd(&mut self, buf: &[u8], fd: RawFd) -> Result<usize>

Block on write

Source§

impl MioAdapter<TcpListener>

Source

pub fn local_addr(&self) -> Result<SocketAddr>

Local address

Source

pub fn take_socket_error(&self) -> Result<()>

TODO: document

Source

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

Try cloning the listener descriptor.

Source§

impl MioAdapter<TcpListener>

Source

pub fn bind(addr: &SocketAddr) -> Result<Self>

Bind to a port

Source

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>

Source

pub fn connect(addr: &SocketAddr) -> Result<Self>

Create a new TCP stream an issue a non-blocking connect to the specified address.

Source

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.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

Local address of connection.

Source

pub fn peer_addr(&self) -> Result<SocketAddr>

Peer address of connection.

Source

pub fn shutdown(&self, how: Shutdown) -> Result<()>

Shutdown the connection.

Source

pub fn set_nodelay(&self, nodelay: bool) -> Result<()>

Set no_delay.

Source

pub fn set_keepalive(&self, seconds: Option<u32>) -> Result<()>

Set keepalive.

Source

pub fn take_socket_error(&self) -> Result<()>

TODO: document

Source

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

Try cloning the socket descriptor.

Source§

impl MioAdapter<UdpSocket>

Source

pub fn v4() -> Result<Self>

Return a new unbound IPv4 UDP Socket.

Source

pub fn v6() -> Result<Self>

Return a new unbound IPv6 UDP Socket.

Source

pub fn bound(addr: &SocketAddr) -> Result<Self>

Return a new bound UDP Socket.

Source

pub fn bind(&self, addr: &SocketAddr) -> Result<()>

Bind the unbound UDP Socket.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

Local address of the Socket.

Source

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

Try cloning the socket.

Source

pub fn recv(&mut self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>

Block on recv.

Source

pub fn try_recv( &mut self, buf: &mut [u8], ) -> Result<Option<(usize, SocketAddr)>>

Try reading data into a buffer.

This will not block.

Source

pub fn send(&mut self, buf: &[u8], target: &SocketAddr) -> Result<usize>

Block on send.

Source

pub fn try_send(&self, buf: &[u8], target: &SocketAddr) -> Result<Option<usize>>

Try writing a data from the buffer.

This will not block.

Source

pub fn set_broadcast(&self, on: bool) -> Result<()>

Set broadcast flag.

Source

pub fn set_multicast_loop(&self, on: bool) -> Result<()>

Set multicast loop flag.

Source

pub fn join_multicast(&self, multi: &IpAddr) -> Result<()>

Join multicast.

Source

pub fn leave_multicast(&self, multi: &IpAddr) -> Result<()>

Leave multicast.

Source

pub fn set_multicast_time_to_live(&self, ttl: i32) -> Result<()>

Set multicast TTL.

Source§

impl<MT> MioAdapter<MT>
where MT: Evented + 'static,

Source

pub fn new(mio_type: MT) -> Self

Create MioAdapter from raw mio type.

Source§

impl<MT> MioAdapter<MT>
where MT: Evented + TryRead + 'static,

Source

pub fn try_read(&mut self, buf: &mut [u8]) -> Result<Option<usize>>

Try reading data into a buffer.

This will not block.

Source§

impl<MT> MioAdapter<MT>
where MT: Evented + 'static + TryWrite,

Source

pub fn try_write(&self, buf: &[u8]) -> Result<Option<usize>>

Try writing a data from the buffer.

This will not block.

Source§

impl<MT, O> MioAdapter<MT>
where MT: Evented + 'static + TryAccept<Output = O>, O: Evented + 'static,

Source

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>
where MT: Evented + 'static + TryAccept<Output = O>, O: Evented + 'static,

Source

pub fn accept(&self) -> Result<MioAdapter<O>>

Block on accepting a connection.

Trait Implementations§

Source§

impl<MT> AsRawFd for MioAdapter<MT>
where MT: Evented + 'static + AsRawFd,

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl<MT> EventedImpl for MioAdapter<MT>
where MT: Evented + 'static,

Source§

type Raw = MT

Raw IO type wrapped by this EventImpl
Source§

fn shared(&self) -> &RcEventSource<Self::Raw>

Get the wrapped io
Source§

impl<MT> FromRawFd for MioAdapter<MT>
where MT: Evented + 'static + FromRawFd,

Source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor. Read more
Source§

impl<MT> Read for MioAdapter<MT>
where MT: Evented + TryRead + 'static,

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Block on read.

1.36.0 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more
Source§

impl<MT> Write for MioAdapter<MT>
where MT: Evented + 'static + TryWrite,

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Block on write.

Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
Source§

impl<T> Send for MioAdapter<T>
where T: Evented + Send,

Auto Trait Implementations§

§

impl<MT> Freeze for MioAdapter<MT>

§

impl<MT> !RefUnwindSafe for MioAdapter<MT>

§

impl<MT> !Sync for MioAdapter<MT>

§

impl<MT> Unpin for MioAdapter<MT>

§

impl<MT> !UnwindSafe for MioAdapter<MT>

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<R, EP> Evented for EP
where EP: EventedImpl<Raw = R>, R: EventSourceTrait + 'static,

Source§

unsafe fn select_add(&self, rw: RW)

Add event source to next select operation. Read more
Source§

fn block_on(&self, rw: RW)

Source§

fn id(&self) -> EventSourceId

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> TryRead for T
where T: Read,

Source§

fn try_read(&mut self, dst: &mut [u8]) -> Result<Option<usize>, Error>

Source§

fn try_read_buf<B>(&mut self, buf: &mut B) -> Result<Option<usize>, Error>
where B: MutBuf, Self: Sized,

Source§

impl<T> TryWrite for T
where T: Write,

Source§

fn try_write(&mut self, src: &[u8]) -> Result<Option<usize>, Error>

Source§

fn try_write_buf<B>(&mut self, buf: &mut B) -> Result<Option<usize>, Error>
where B: Buf, Self: Sized,

Source§

impl<T> Erased for T