Skip to main content

TcpStream

Struct TcpStream 

Source
pub struct TcpStream { /* private fields */ }
Available on crate feature net only.
Expand description

A TCP stream between a local and a remote socket.

A TCP stream can either be created by connecting to an endpoint, via the connect method, or by accepting a connection from a listener.

§Examples

use std::net::SocketAddr;

use compio_io::AsyncWrite;
use compio_net::TcpStream;

// Connect to a peer
let mut stream = TcpStream::connect("127.0.0.1:8080").await.unwrap();

// Write some data.
stream.write("hello world!").await.unwrap();

Implementations§

Source§

impl TcpStream

Source

pub async fn connect(addr: impl ToSocketAddrsAsync) -> Result<TcpStream, Error>

Opens a TCP connection to a remote host.

To configure the socket before connecting, you can use the TcpSocket type.

Source

pub fn from_std(stream: TcpStream) -> Result<TcpStream, Error>

Creates new TcpStream from a std::net::TcpStream.

Source

pub fn close(self) -> impl Future<Output = Result<(), Error>>

Close the socket. If the returned future is dropped before polling, the socket won’t be closed.

As the socket is clonable, users can call close on a clone, but the future will never complete until all clones are dropped. Some operations may keep a strong reference to the socket, so the future may never complete if there are pending operations.

It’s OK to drop the socket directly without calling close, but the socket may not be closed immediately.

Source

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

Returns the socket address of the remote peer of this TCP connection.

Source

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

Returns the socket address of the local half of this TCP connection.

Source

pub fn take_error(&self) -> Result<Option<Error>, Error>

Returns the value of the SO_ERROR option.

Source

pub fn split(&self) -> (ReadHalf<'_, TcpStream>, WriteHalf<'_, TcpStream>)

Splits a TcpStream into a read half and a write half, which can be used to read and write the stream concurrently.

This method is more efficient than into_split, but the halves cannot be moved into independently spawned tasks.

Source

pub fn into_split(self) -> (TcpStream, TcpStream)

Splits a TcpStream into a read half and a write half, which can be used to read and write the stream concurrently.

Unlike split, the owned halves can be moved to separate tasks.

Source

pub fn to_poll_fd(&self) -> Result<PollFd<Socket>, Error>

Create PollFd from inner socket.

Source

pub fn into_poll_fd(self) -> Result<PollFd<Socket>, Error>

Create PollFd from inner socket.

Source

pub async fn disconnect(self) -> Result<TcpSocket, Error>

Available on Windows only.

Close the connection of the socket, and reuse it to create a new connection. This method is useful when the socket is created by TcpListener::accept, and will be reused in TcpListener::accept_with to accept a new connection.

Source

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

Gets the value of the TCP_NODELAY option on this socket.

For more information about this option, see TcpStream::set_nodelay.

Source

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

Sets the value of the TCP_NODELAY option on this socket.

If set, this option disables the Nagle algorithm. This means that segments are always sent as soon as possible, even if there is only a small amount of data. When not set, data is buffered until there is a sufficient amount to send out, thereby avoiding the frequent sending of small packets.

Source

pub fn linger(&self) -> Result<Option<Duration>, Error>

Reads the linger duration for this socket by getting the SO_LINGER option.

Source

pub fn set_zero_linger(&self) -> Result<(), Error>

Sets a linger duration of zero on this socket by setting the SO_LINGER option.

Source

pub fn ttl_v4(&self) -> Result<u32, Error>

Gets the value of the IP_TTL option for this socket.

For more information about this option, see set_ttl_v4.

Source

pub fn set_ttl_v4(&self, ttl: u32) -> Result<(), Error>

Sets the value for the IP_TTL option on this socket.

This value sets the time-to-live field that is used in every packet sent from this socket.

Source

pub async fn send_out_of_band<T>(&self, buf: T) -> BufResult<usize, T>
where T: IoBuf,

Sends out-of-band data on this socket.

Out-of-band data is sent with the MSG_OOB flag.

Trait Implementations§

Source§

impl AsRawFd for TcpStream

Source§

fn as_raw_fd(&self) -> *mut c_void

Extracts the raw fd.
Source§

impl AsRawSocket for TcpStream

Available on Windows only.
Source§

fn as_raw_socket(&self) -> u64

Extracts the raw socket. Read more
Source§

impl AsSocket for TcpStream

Available on Windows only.
Source§

fn as_socket(&self) -> BorrowedSocket<'_>

Borrows the socket.
Source§

impl AsyncRead for &TcpStream

Source§

async fn read<B>(&mut self, buf: B) -> BufResult<usize, B>
where B: IoBufMut,

Read some bytes from this source into the IoBufMut buffer and return a BufResult, consisting of the buffer and a usize indicating how many bytes were read. Read more
Source§

async fn read_vectored<V>(&mut self, buf: V) -> BufResult<usize, V>

Like read, except that it reads into a type implements IoVectoredBufMut. Read more
Source§

impl AsyncRead for TcpStream

Source§

async fn read<B>(&mut self, buf: B) -> BufResult<usize, B>
where B: IoBufMut,

Read some bytes from this source into the IoBufMut buffer and return a BufResult, consisting of the buffer and a usize indicating how many bytes were read. Read more
Source§

async fn read_vectored<V>(&mut self, buf: V) -> BufResult<usize, V>

Like read, except that it reads into a type implements IoVectoredBufMut. Read more
Source§

impl AsyncReadAncillary for &TcpStream

Source§

async fn read_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<(usize, usize), (T, C)>
where T: IoBufMut, C: IoBufMut,

Read data with ancillary data into an owned buffer.
Source§

async fn read_vectored_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<(usize, usize), (T, C)>

Read data with ancillary data into a vectored buffer.
Source§

impl AsyncReadAncillary for TcpStream

Source§

async fn read_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<(usize, usize), (T, C)>
where T: IoBufMut, C: IoBufMut,

Read data with ancillary data into an owned buffer.
Source§

async fn read_vectored_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<(usize, usize), (T, C)>

Read data with ancillary data into a vectored buffer.
Source§

impl AsyncReadAncillaryManaged for &TcpStream

Source§

async fn read_managed_with_ancillary<C>( &mut self, len: usize, control: C, ) -> Result<Option<(<&TcpStream as AsyncReadManaged>::Buffer, C)>, Error>
where C: IoBufMut,

Read data into a managed buffer with ancillary data. Read more
Source§

impl AsyncReadAncillaryManaged for TcpStream

Source§

async fn read_managed_with_ancillary<C>( &mut self, len: usize, control: C, ) -> Result<Option<(<TcpStream as AsyncReadManaged>::Buffer, C)>, Error>
where C: IoBufMut,

Read data into a managed buffer with ancillary data. Read more
Source§

impl AsyncReadAncillaryMulti for &TcpStream

Source§

type Return = RecvMsgMultiResult

A wrapped type for the payload data and the ancillary data.
Source§

fn read_multi_with_ancillary( &mut self, control_len: usize, ) -> impl Stream<Item = Result<<&TcpStream as AsyncReadAncillaryMulti>::Return, Error>>

Read data and ancillary data into multiple managed buffers.
Source§

impl AsyncReadAncillaryMulti for TcpStream

Source§

type Return = RecvMsgMultiResult

A wrapped type for the payload data and the ancillary data.
Source§

fn read_multi_with_ancillary( &mut self, control_len: usize, ) -> impl Stream<Item = Result<<TcpStream as AsyncReadAncillaryMulti>::Return, Error>>

Read data and ancillary data into multiple managed buffers.
Source§

impl AsyncReadManaged for &TcpStream

Source§

type Buffer = BufferRef

Filled buffer type
Source§

async fn read_managed( &mut self, len: usize, ) -> Result<Option<<&TcpStream as AsyncReadManaged>::Buffer>, Error>

Read some bytes from this source and return a Self::Buffer. Read more
Source§

impl AsyncReadManaged for TcpStream

Source§

type Buffer = BufferRef

Filled buffer type
Source§

async fn read_managed( &mut self, len: usize, ) -> Result<Option<<TcpStream as AsyncReadManaged>::Buffer>, Error>

Read some bytes from this source and return a Self::Buffer. Read more
Source§

impl AsyncReadMulti for &TcpStream

Source§

fn read_multi( &mut self, len: usize, ) -> impl Stream<Item = Result<<&TcpStream as AsyncReadManaged>::Buffer, Error>>

Read some bytes from this source and return a stream of AsyncReadManaged::Buffer. Read more
Source§

impl AsyncReadMulti for TcpStream

Source§

fn read_multi( &mut self, len: usize, ) -> impl Stream<Item = Result<<TcpStream as AsyncReadManaged>::Buffer, Error>>

Read some bytes from this source and return a stream of AsyncReadManaged::Buffer. Read more
Source§

impl AsyncWrite for &TcpStream

Source§

async fn write<T>(&mut self, buf: T) -> BufResult<usize, T>
where T: IoBuf,

Write some bytes from the buffer into this source and return a BufResult, consisting of the buffer and a usize indicating how many bytes were written.
Source§

async fn write_vectored<T>(&mut self, buf: T) -> BufResult<usize, T>
where T: IoVectoredBuf,

Like write, except that it write bytes from a buffer implements IoVectoredBuf into the source. Read more
Source§

async fn flush(&mut self) -> Result<(), Error>

Attempts to flush the object, ensuring that any buffered data reach their destination.
Source§

async fn shutdown(&mut self) -> Result<(), Error>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down.
Source§

impl AsyncWrite for TcpStream

Source§

async fn write<T>(&mut self, buf: T) -> BufResult<usize, T>
where T: IoBuf,

Write some bytes from the buffer into this source and return a BufResult, consisting of the buffer and a usize indicating how many bytes were written.
Source§

async fn write_vectored<T>(&mut self, buf: T) -> BufResult<usize, T>
where T: IoVectoredBuf,

Like write, except that it write bytes from a buffer implements IoVectoredBuf into the source. Read more
Source§

async fn flush(&mut self) -> Result<(), Error>

Attempts to flush the object, ensuring that any buffered data reach their destination.
Source§

async fn shutdown(&mut self) -> Result<(), Error>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down.
Source§

impl AsyncWriteAncillary for &TcpStream

Source§

async fn write_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<usize, (T, C)>
where T: IoBuf, C: IoBuf,

Write data with ancillary data from an owned buffer.
Source§

async fn write_vectored_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<usize, (T, C)>
where T: IoVectoredBuf, C: IoBuf,

Write data with ancillary data from a vectored buffer.
Source§

impl AsyncWriteAncillary for TcpStream

Source§

async fn write_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<usize, (T, C)>
where T: IoBuf, C: IoBuf,

Write data with ancillary data from an owned buffer.
Source§

async fn write_vectored_with_ancillary<T, C>( &mut self, buffer: T, control: C, ) -> BufResult<usize, (T, C)>
where T: IoVectoredBuf, C: IoBuf,

Write data with ancillary data from a vectored buffer.
Source§

impl AsyncWriteAncillaryZerocopy for &TcpStream

Source§

type BufferReadyFuture<T: IoBuf, C: IoBuf> = Extract<Zerocopy<SendMsg<[T; 1], C, SharedFd<Socket>>>, T, C>

The future that will be resolved when the buffer is safe to be reused.
Source§

type VectoredBufferReadyFuture<T: IoVectoredBuf, C: IoBuf> = Zerocopy<SendMsg<T, C, SharedFd<Socket>>>

The future that will be resolved when the vectored buffer is safe to be reused.
Source§

async fn write_zerocopy_with_ancillary<T, C>( &mut self, buf: T, control: C, ) -> BufResult<usize, <&TcpStream as AsyncWriteAncillaryZerocopy>::BufferReadyFuture<T, C>>
where T: IoBuf, C: IoBuf,

Write some bytes from buffer into this source using the underlying zero-copy mechanism. It returns a result of the underlying write operation and a future that will be resolved when the buffer is safe to be reused.
Source§

async fn write_zerocopy_vectored_with_ancillary<T, C>( &mut self, buf: T, control: C, ) -> BufResult<usize, <&TcpStream as AsyncWriteAncillaryZerocopy>::VectoredBufferReadyFuture<T, C>>
where T: IoVectoredBuf, C: IoBuf,

Like write_zerocopy_with_ancillary, except that it writes from a buffer implements IoVectoredBuf into the source.
Source§

impl AsyncWriteAncillaryZerocopy for TcpStream

Source§

type BufferReadyFuture<T: IoBuf, C: IoBuf> = Extract<Zerocopy<SendMsg<[T; 1], C, SharedFd<Socket>>>, T, C>

The future that will be resolved when the buffer is safe to be reused.
Source§

type VectoredBufferReadyFuture<T: IoVectoredBuf, C: IoBuf> = Zerocopy<SendMsg<T, C, SharedFd<Socket>>>

The future that will be resolved when the vectored buffer is safe to be reused.
Source§

async fn write_zerocopy_with_ancillary<T, C>( &mut self, buf: T, control: C, ) -> BufResult<usize, <TcpStream as AsyncWriteAncillaryZerocopy>::BufferReadyFuture<T, C>>
where T: IoBuf, C: IoBuf,

Write some bytes from buffer into this source using the underlying zero-copy mechanism. It returns a result of the underlying write operation and a future that will be resolved when the buffer is safe to be reused.
Source§

async fn write_zerocopy_vectored_with_ancillary<T, C>( &mut self, buf: T, control: C, ) -> BufResult<usize, <TcpStream as AsyncWriteAncillaryZerocopy>::VectoredBufferReadyFuture<T, C>>
where T: IoVectoredBuf, C: IoBuf,

Like write_zerocopy_with_ancillary, except that it writes from a buffer implements IoVectoredBuf into the source.
Source§

impl AsyncWriteZerocopy for &TcpStream

Source§

type BufferReadyFuture<T: IoBuf> = Zerocopy<Send<T, SharedFd<Socket>>>

The future that will be resolved when the buffer is safe to be reused.
Source§

type VectoredBufferReadyFuture<T: IoVectoredBuf> = Zerocopy<SendVectored<T, SharedFd<Socket>>>

The future that will be resolved when the vectored buffer is safe to be reused.
Source§

async fn write_zerocopy<T>( &mut self, buf: T, ) -> BufResult<usize, <&TcpStream as AsyncWriteZerocopy>::BufferReadyFuture<T>>
where T: IoBuf,

Write some bytes from buffer into this source using the underlying zero-copy mechanism. It returns a result of the underlying write operation and a future that will be resolved when the buffer is safe to be reused.
Source§

async fn write_zerocopy_vectored<T>( &mut self, buf: T, ) -> BufResult<usize, <&TcpStream as AsyncWriteZerocopy>::VectoredBufferReadyFuture<T>>
where T: IoVectoredBuf,

Like write_zerocopy, except that it writes from a buffer implements IoVectoredBuf into the source.
Source§

impl AsyncWriteZerocopy for TcpStream

Source§

type BufferReadyFuture<T: IoBuf> = Zerocopy<Send<T, SharedFd<Socket>>>

The future that will be resolved when the buffer is safe to be reused.
Source§

type VectoredBufferReadyFuture<T: IoVectoredBuf> = Zerocopy<SendVectored<T, SharedFd<Socket>>>

The future that will be resolved when the vectored buffer is safe to be reused.
Source§

async fn write_zerocopy<T>( &mut self, buf: T, ) -> BufResult<usize, <TcpStream as AsyncWriteZerocopy>::BufferReadyFuture<T>>
where T: IoBuf,

Write some bytes from buffer into this source using the underlying zero-copy mechanism. It returns a result of the underlying write operation and a future that will be resolved when the buffer is safe to be reused.
Source§

async fn write_zerocopy_vectored<T>( &mut self, buf: T, ) -> BufResult<usize, <TcpStream as AsyncWriteZerocopy>::VectoredBufferReadyFuture<T>>
where T: IoVectoredBuf,

Like write_zerocopy, except that it writes from a buffer implements IoVectoredBuf into the source.
Source§

impl Clone for TcpStream

Source§

fn clone(&self) -> TcpStream

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TcpStream

Source§

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

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

impl FromRawSocket for TcpStream

Available on Windows only.
Source§

unsafe fn from_raw_socket(sock: u64) -> TcpStream

Constructs a new I/O object from the specified raw socket. Read more
Source§

impl<'a> Splittable for &'a TcpStream

Source§

type ReadHalf = ReadHalf<'a, TcpStream>

The type of the read half, which normally implements AsyncRead or AsyncReadAt.
Source§

type WriteHalf = WriteHalf<'a, TcpStream>

The type of the write half, which normally implements AsyncWrite or AsyncWriteAt.
Source§

fn split( self, ) -> (<&'a TcpStream as Splittable>::ReadHalf, <&'a TcpStream as Splittable>::WriteHalf)

Consumes self and returns a tuple containing separate read and write halves. Read more
Source§

impl<'a> Splittable for &'a mut TcpStream

Source§

type ReadHalf = ReadHalf<'a, TcpStream>

The type of the read half, which normally implements AsyncRead or AsyncReadAt.
Source§

type WriteHalf = WriteHalf<'a, TcpStream>

The type of the write half, which normally implements AsyncWrite or AsyncWriteAt.
Source§

fn split( self, ) -> (<&'a mut TcpStream as Splittable>::ReadHalf, <&'a mut TcpStream as Splittable>::WriteHalf)

Consumes self and returns a tuple containing separate read and write halves. Read more
Source§

impl Splittable for TcpStream

Source§

type ReadHalf = TcpStream

The type of the read half, which normally implements AsyncRead or AsyncReadAt.
Source§

type WriteHalf = TcpStream

The type of the write half, which normally implements AsyncWrite or AsyncWriteAt.
Source§

fn split( self, ) -> (<TcpStream as Splittable>::ReadHalf, <TcpStream as Splittable>::WriteHalf)

Consumes self and returns a tuple containing separate read and write halves. Read more
Source§

impl ToSharedFd<Socket> for TcpStream

Source§

fn to_shared_fd(&self) -> SharedFd<Socket>

Return a cloned SharedFd.

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
§

impl<T> AsFd for T
where T: AsSocket,

§

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

An as_fd function for Winsock, where an Fd is a Socket.
§

impl<T> AsRawFd for T
where T: AsRawSocket,

§

fn as_raw_fd(&self) -> u64

A version of as_raw_fd for use with Winsock API.
§

impl<T> AsRawSocketlike for T
where T: AsRawSocket,

§

fn as_raw_socketlike(&self) -> u64

Returns the raw value.
§

impl<T> AsRawSocketlike for T
where T: AsRawSocket,

§

fn as_raw_socketlike(&self) -> u64

Returns the raw value.
§

impl<T> AsSocketlike for T
where T: AsSocket,

§

fn as_socketlike(&self) -> BorrowedSocket<'_>

Borrows the reference.
§

fn as_socketlike_view<Target>(&self) -> SocketlikeView<'_, Target>
where Target: SocketlikeViewType,

Return a borrowing view of a resource which dereferences to a &Target. Read more
§

impl<T> AsSocketlike for T
where T: AsSocket,

§

fn as_socketlike(&self) -> BorrowedSocket<'_>

Borrows the reference.
§

fn as_socketlike_view<Target>(&self) -> SocketlikeView<'_, Target>
where Target: SocketlikeViewType,

Return a borrowing view of a resource which dereferences to a &Target. Read more
§

impl<A> AsyncReadExt for A
where A: AsyncRead + ?Sized,

§

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

Creates a “by reference” adaptor for this instance of AsyncRead. Read more
§

async fn append<T>(&mut self, buf: T) -> BufResult<usize, T>
where T: IoBufMut,

Same as AsyncRead::read, but it appends data to the end of the buffer; in other words, it read to the beginning of the uninitialized area.
§

async fn read_exact<T>(&mut self, buf: T) -> BufResult<(), T>
where T: IoBufMut,

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

async fn read_to_string(&mut self, buf: String) -> BufResult<usize, String>

Read all bytes as String until underlying reader reaches EOF.
§

async fn read_to_end<A>( &mut self, buf: Vec<u8, A>, ) -> BufResult<usize, Vec<u8, A>>
where A: Allocator + 'static,

Read all bytes until underlying reader reaches EOF.
§

async fn read_vectored_exact<T>(&mut self, buf: T) -> BufResult<(), T>

Read the exact number of bytes required to fill the vectored buf.
§

fn framed<T, C, F>( self, codec: C, framer: F, ) -> Framed<Self::ReadHalf, Self::WriteHalf, C, F, T, T>
where Self: Sized + Splittable,

Create a framed::Framed reader/writer with the given codec and framer.
§

fn bytes( self, ) -> Framed<Self::ReadHalf, Self::WriteHalf, BytesCodec, NoopFramer, Bytes, Bytes>
where Self: Sized + Splittable,

Available on crate feature bytes only.
Convenience method to create a framed::BytesFramed reader/writter out of a splittable.
§

fn read_only(self) -> ReadOnly<Self>
where Self: Sized,

Create a Splittable that uses Self as ReadHalf and () as WriteHalf. Read more
§

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

Creates an adaptor which reads at most limit bytes from it. Read more
§

async fn read_u8(&mut self) -> Result<u8, Error>

Read a big endian u8 from the underlying reader.
§

async fn read_u8_le(&mut self) -> Result<u8, Error>

Read a little endian u8 from the underlying reader.
§

async fn read_u16(&mut self) -> Result<u16, Error>

Read a big endian u16 from the underlying reader.
§

async fn read_u16_le(&mut self) -> Result<u16, Error>

Read a little endian u16 from the underlying reader.
§

async fn read_u32(&mut self) -> Result<u32, Error>

Read a big endian u32 from the underlying reader.
§

async fn read_u32_le(&mut self) -> Result<u32, Error>

Read a little endian u32 from the underlying reader.
§

async fn read_u64(&mut self) -> Result<u64, Error>

Read a big endian u64 from the underlying reader.
§

async fn read_u64_le(&mut self) -> Result<u64, Error>

Read a little endian u64 from the underlying reader.
§

async fn read_u128(&mut self) -> Result<u128, Error>

Read a big endian u128 from the underlying reader.
§

async fn read_u128_le(&mut self) -> Result<u128, Error>

Read a little endian u128 from the underlying reader.
§

async fn read_i8(&mut self) -> Result<i8, Error>

Read a big endian i8 from the underlying reader.
§

async fn read_i8_le(&mut self) -> Result<i8, Error>

Read a little endian i8 from the underlying reader.
§

async fn read_i16(&mut self) -> Result<i16, Error>

Read a big endian i16 from the underlying reader.
§

async fn read_i16_le(&mut self) -> Result<i16, Error>

Read a little endian i16 from the underlying reader.
§

async fn read_i32(&mut self) -> Result<i32, Error>

Read a big endian i32 from the underlying reader.
§

async fn read_i32_le(&mut self) -> Result<i32, Error>

Read a little endian i32 from the underlying reader.
§

async fn read_i64(&mut self) -> Result<i64, Error>

Read a big endian i64 from the underlying reader.
§

async fn read_i64_le(&mut self) -> Result<i64, Error>

Read a little endian i64 from the underlying reader.
§

async fn read_i128(&mut self) -> Result<i128, Error>

Read a big endian i128 from the underlying reader.
§

async fn read_i128_le(&mut self) -> Result<i128, Error>

Read a little endian i128 from the underlying reader.
§

async fn read_f32(&mut self) -> Result<f32, Error>

Read a big endian f32 from the underlying reader.
§

async fn read_f32_le(&mut self) -> Result<f32, Error>

Read a little endian f32 from the underlying reader.
§

async fn read_f64(&mut self) -> Result<f64, Error>

Read a big endian f64 from the underlying reader.
§

async fn read_f64_le(&mut self) -> Result<f64, Error>

Read a little endian f64 from the underlying reader.
§

impl<A> AsyncWriteExt for A
where A: AsyncWrite + ?Sized,

§

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

Creates a “by reference” adaptor for this instance of AsyncWrite. Read more
§

async fn write_all<T>(&mut self, buf: T) -> BufResult<(), T>
where T: IoBuf,

Write the entire contents of a buffer into this writer.
§

async fn write_vectored_all<T>(&mut self, buf: T) -> BufResult<(), T>
where T: IoVectoredBuf,

Write the entire contents of a buffer into this writer. Like AsyncWrite::write_vectored, except that it tries to write the entire contents of the buffer into this writer.
§

fn framed<T, C, F>( self, codec: C, framer: F, ) -> Framed<Self::ReadHalf, Self::WriteHalf, C, F, T, T>
where Self: Sized + Splittable,

Create a framed::Framed reader/writer with the given codec and framer.
§

fn bytes( self, ) -> Framed<Self::ReadHalf, Self::WriteHalf, BytesCodec, NoopFramer, Bytes, Bytes>
where Self: Sized + Splittable,

Available on crate feature bytes only.
Convenience method to create a framed::BytesFramed reader/writer out of a splittable.
§

fn write_only(self) -> WriteOnly<Self>
where Self: Sized,

Create a Splittable that uses Self as WriteHalf and () as ReadHalf. Read more
§

async fn write_u8(&mut self, num: u8) -> Result<(), Error>

Write a big endian u8 into the underlying writer.
§

async fn write_u8_le(&mut self, num: u8) -> Result<(), Error>

Write a little endian u8 into the underlying writer.
§

async fn write_u16(&mut self, num: u16) -> Result<(), Error>

Write a big endian u16 into the underlying writer.
§

async fn write_u16_le(&mut self, num: u16) -> Result<(), Error>

Write a little endian u16 into the underlying writer.
§

async fn write_u32(&mut self, num: u32) -> Result<(), Error>

Write a big endian u32 into the underlying writer.
§

async fn write_u32_le(&mut self, num: u32) -> Result<(), Error>

Write a little endian u32 into the underlying writer.
§

async fn write_u64(&mut self, num: u64) -> Result<(), Error>

Write a big endian u64 into the underlying writer.
§

async fn write_u64_le(&mut self, num: u64) -> Result<(), Error>

Write a little endian u64 into the underlying writer.
§

async fn write_u128(&mut self, num: u128) -> Result<(), Error>

Write a big endian u128 into the underlying writer.
§

async fn write_u128_le(&mut self, num: u128) -> Result<(), Error>

Write a little endian u128 into the underlying writer.
§

async fn write_i8(&mut self, num: i8) -> Result<(), Error>

Write a big endian i8 into the underlying writer.
§

async fn write_i8_le(&mut self, num: i8) -> Result<(), Error>

Write a little endian i8 into the underlying writer.
§

async fn write_i16(&mut self, num: i16) -> Result<(), Error>

Write a big endian i16 into the underlying writer.
§

async fn write_i16_le(&mut self, num: i16) -> Result<(), Error>

Write a little endian i16 into the underlying writer.
§

async fn write_i32(&mut self, num: i32) -> Result<(), Error>

Write a big endian i32 into the underlying writer.
§

async fn write_i32_le(&mut self, num: i32) -> Result<(), Error>

Write a little endian i32 into the underlying writer.
§

async fn write_i64(&mut self, num: i64) -> Result<(), Error>

Write a big endian i64 into the underlying writer.
§

async fn write_i64_le(&mut self, num: i64) -> Result<(), Error>

Write a little endian i64 into the underlying writer.
§

async fn write_i128(&mut self, num: i128) -> Result<(), Error>

Write a big endian i128 into the underlying writer.
§

async fn write_i128_le(&mut self, num: i128) -> Result<(), Error>

Write a little endian i128 into the underlying writer.
§

async fn write_f32(&mut self, num: f32) -> Result<(), Error>

Write a big endian f32 into the underlying writer.
§

async fn write_f32_le(&mut self, num: f32) -> Result<(), Error>

Write a little endian f32 into the underlying writer.
§

async fn write_f64(&mut self, num: f64) -> Result<(), Error>

Write a big endian f64 into the underlying writer.
§

async fn write_f64_le(&mut self, num: f64) -> Result<(), Error>

Write a little endian f64 into the underlying writer.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRawFd for T
where T: FromRawSocket,

§

unsafe fn from_raw_fd(raw_fd: u64) -> T

A version of from_raw_fd for use with Winsock API. Read more
§

impl<T> FromRawSocketlike for T
where T: FromRawSocket,

§

unsafe fn from_raw_socketlike(raw: u64) -> T

Constructs Self from the raw value.
§

impl<T> FromRawSocketlike for T
where T: FromRawSocket,

§

unsafe fn from_raw_socketlike(raw: u64) -> T

Constructs Self from the raw value.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<S> IntoMaybeTlsStream<S> for S
where S: Splittable,

Source§

fn into_maybe_tls_stream( self, capacity: usize, max_buffer_size: usize, ) -> MaybeTlsStream<S>

Create MaybeTlsStream with capacity and buffer size limit.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Ungil for T
where T: Send,