Skip to main content

UnixStream

Struct UnixStream 

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

A Unix stream between two local sockets on Windows & WSL.

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

§Examples

use compio_io::AsyncWrite;
use compio_net::UnixStream;

// Connect to a peer
let mut stream = UnixStream::connect("unix-server.sock").await.unwrap();

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

Implementations§

Source§

impl UnixStream

Source

pub async fn connect(path: impl AsRef<Path>) -> Result<UnixStream, Error>

Opens a Unix connection to the specified file path. See UnixStream::connect_addr for more details.

Source

pub async fn connect_addr(addr: &SockAddr) -> Result<UnixStream, Error>

Opens a Unix connection to the specified address. There must be a UnixListener or equivalent listening on the corresponding Unix domain socket to successfully connect and return a UnixStream.

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

Source

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

Available on Unix only.

Creates new UnixStream from a std::os::unix::net::UnixStream.

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.

See TcpStream::close for more details.

Source

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

Returns the socket path of the remote peer of this connection.

Source

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

Returns the socket path of the local half of this 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<'_, UnixStream>, WriteHalf<'_, UnixStream>)

Splits a UnixStream 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) -> (UnixStream, UnixStream)

Splits a UnixStream 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.

Trait Implementations§

Source§

impl AsFd for UnixStream

Available on Unix only.
Source§

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

Borrows the file descriptor. Read more
Source§

impl AsRawFd for UnixStream

Source§

fn as_raw_fd(&self) -> i32

Extracts the raw file descriptor. Read more
Source§

impl AsyncRead for &UnixStream

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 UnixStream

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 &UnixStream

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 UnixStream

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 &UnixStream

Source§

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

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

impl AsyncReadAncillaryManaged for UnixStream

Source§

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

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

impl AsyncReadAncillaryMulti for &UnixStream

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<<&UnixStream as AsyncReadAncillaryMulti>::Return, Error>>

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

impl AsyncReadAncillaryMulti for UnixStream

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<<UnixStream as AsyncReadAncillaryMulti>::Return, Error>>

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

impl AsyncReadManaged for &UnixStream

Source§

type Buffer = BufferRef

Filled buffer type
Source§

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

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

impl AsyncReadManaged for UnixStream

Source§

type Buffer = BufferRef

Filled buffer type
Source§

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

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

impl AsyncReadMulti for &UnixStream

Source§

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

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

impl AsyncReadMulti for UnixStream

Source§

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

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

impl AsyncWrite for &UnixStream

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 UnixStream

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 &UnixStream

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 UnixStream

§Example

Send and receive a file descriptor over a Unix socket pair using SCM_RIGHTS:

use std::os::unix::io::RawFd;

use compio_io::ancillary::*;
use compio_net::UnixStream;

const BUF_SIZE: usize = ancillary_space::<RawFd>();

// Create a socket pair.
let (std_a, std_b) = std::os::unix::net::UnixStream::pair().unwrap();
let mut a = UnixStream::from_std(std_a).unwrap();
let mut b = UnixStream::from_std(std_b).unwrap();

// Pass fd 0 (stdin) as ancillary data via SCM_RIGHTS.
let mut ctrl_send = AncillaryBuf::<BUF_SIZE>::new();
let mut builder = ctrl_send.builder();
builder
    .push(libc::SOL_SOCKET, libc::SCM_RIGHTS, &(0 as RawFd))
    .unwrap();

// Send the payload together with the ancillary data.
a.write_with_ancillary(b"hello", ctrl_send).await.0.unwrap();

// Receive on the other end.
let payload = Vec::with_capacity(5);
let ctrl_recv = AncillaryBuf::<BUF_SIZE>::new();
let ((_, ctrl_len), (payload, ctrl_recv)) =
    b.read_with_ancillary(payload, ctrl_recv).await.unwrap();

assert_eq!(&payload[..], b"hello");

// Parse the received ancillary messages.
let mut iter = unsafe { AncillaryIter::new(&ctrl_recv[..ctrl_len]) };
let msg = iter.next().unwrap();
assert_eq!(msg.level(), libc::SOL_SOCKET);
assert_eq!(msg.ty(), libc::SCM_RIGHTS);
// The kernel duplicates the fd, so the received value may differ.
let _received_fd = unsafe { msg.data::<RawFd>() };
assert!(iter.next().is_none());
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 &UnixStream

Source§

type BufferReadyFuture<T: IoBuf, C: IoBuf> = Extract<Zerocopy<SendMsgZc<[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<SendMsgZc<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, <&UnixStream 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, <&UnixStream 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 UnixStream

Source§

type BufferReadyFuture<T: IoBuf, C: IoBuf> = Extract<Zerocopy<SendMsgZc<[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<SendMsgZc<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, <UnixStream 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, <UnixStream 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 &UnixStream

Source§

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

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

type VectoredBufferReadyFuture<T: IoVectoredBuf> = Zerocopy<SendVectoredZc<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, <&UnixStream 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, <&UnixStream 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 UnixStream

Source§

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

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

type VectoredBufferReadyFuture<T: IoVectoredBuf> = Zerocopy<SendVectoredZc<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, <UnixStream 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, <UnixStream 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 UnixStream

Source§

fn clone(&self) -> UnixStream

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 UnixStream

Source§

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

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

impl FromRawFd for UnixStream

Available on Unix only.
Source§

unsafe fn from_raw_fd(fd: i32) -> UnixStream

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

impl<'a> Splittable for &'a UnixStream

Source§

type ReadHalf = ReadHalf<'a, UnixStream>

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

type WriteHalf = WriteHalf<'a, UnixStream>

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

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

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

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

Source§

type ReadHalf = ReadHalf<'a, UnixStream>

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

type WriteHalf = WriteHalf<'a, UnixStream>

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

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

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

impl Splittable for UnixStream

Source§

type ReadHalf = UnixStream

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

type WriteHalf = UnixStream

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

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

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

impl ToSharedFd<Socket> for UnixStream

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> AsSource for T
where T: AsFd,

§

fn source(&self) -> BorrowedFd<'_>

Returns the borrowed file descriptor.
Source§

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

Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Read a big endian u8 from the underlying reader.
Source§

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

Read a little endian u8 from the underlying reader.
Source§

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

Read a big endian u16 from the underlying reader.
Source§

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

Read a little endian u16 from the underlying reader.
Source§

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

Read a big endian u32 from the underlying reader.
Source§

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

Read a little endian u32 from the underlying reader.
Source§

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

Read a big endian u64 from the underlying reader.
Source§

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

Read a little endian u64 from the underlying reader.
Source§

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

Read a big endian u128 from the underlying reader.
Source§

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

Read a little endian u128 from the underlying reader.
Source§

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

Read a big endian i8 from the underlying reader.
Source§

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

Read a little endian i8 from the underlying reader.
Source§

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

Read a big endian i16 from the underlying reader.
Source§

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

Read a little endian i16 from the underlying reader.
Source§

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

Read a big endian i32 from the underlying reader.
Source§

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

Read a little endian i32 from the underlying reader.
Source§

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

Read a big endian i64 from the underlying reader.
Source§

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

Read a little endian i64 from the underlying reader.
Source§

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

Read a big endian i128 from the underlying reader.
Source§

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

Read a little endian i128 from the underlying reader.
Source§

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

Read a big endian f32 from the underlying reader.
Source§

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

Read a little endian f32 from the underlying reader.
Source§

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

Read a big endian f64 from the underlying reader.
Source§

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

Read a little endian f64 from the underlying reader.
Source§

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

Source§

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

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

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

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

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

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

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

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

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

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

Write a big endian u8 into the underlying writer.
Source§

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

Write a little endian u8 into the underlying writer.
Source§

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

Write a big endian u16 into the underlying writer.
Source§

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

Write a little endian u16 into the underlying writer.
Source§

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

Write a big endian u32 into the underlying writer.
Source§

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

Write a little endian u32 into the underlying writer.
Source§

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

Write a big endian u64 into the underlying writer.
Source§

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

Write a little endian u64 into the underlying writer.
Source§

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

Write a big endian u128 into the underlying writer.
Source§

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

Write a little endian u128 into the underlying writer.
Source§

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

Write a big endian i8 into the underlying writer.
Source§

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

Write a little endian i8 into the underlying writer.
Source§

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

Write a big endian i16 into the underlying writer.
Source§

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

Write a little endian i16 into the underlying writer.
Source§

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

Write a big endian i32 into the underlying writer.
Source§

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

Write a little endian i32 into the underlying writer.
Source§

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

Write a big endian i64 into the underlying writer.
Source§

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

Write a little endian i64 into the underlying writer.
Source§

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

Write a big endian i128 into the underlying writer.
Source§

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

Write a little endian i128 into the underlying writer.
Source§

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

Write a big endian f32 into the underlying writer.
Source§

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

Write a little endian f32 into the underlying writer.
Source§

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

Write a big endian f64 into the underlying writer.
Source§

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> 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,