Struct UnixStream

Source
pub struct UnixStream { /* private fields */ }
Expand description

UnixStream

Implementations§

Source§

impl UnixStream

Source

pub async fn connect<P: AsRef<Path>>(path: P) -> Result<Self>

Connect UnixStream to a path.

Source

pub async fn connect_addr(addr: SocketAddr) -> Result<Self>

Connects the socket to an address.

Source

pub fn pair() -> Result<(Self, Self)>

Creates an unnamed pair of connected sockets.

Returns two UnixStreams which are connected to each other.

Source

pub fn peer_cred(&self) -> Result<UCred>

Returns effective credentials of the process which called connect or pair.

Source

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

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

Source

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

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

Source

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

Returns the socket address of the remote half of this connection.

Source

pub async fn readable(&self, relaxed: bool) -> Result<()>

Wait for read readiness. Note: Do not use it before every io. It is different from other runtimes!

Everytime call to this method may pay a syscall cost. In uring impl, it will push a PollAdd op; in epoll impl, it will use use inner readiness state; if !relaxed, it will call syscall poll after that.

If relaxed, on legacy driver it may return false positive result. If you want to do io by your own, you must maintain io readiness and wait for io ready with relaxed=false.

Source

pub async fn writable(&self, relaxed: bool) -> Result<()>

Wait for write readiness. Note: Do not use it before every io. It is different from other runtimes!

Everytime call to this method may pay a syscall cost. In uring impl, it will push a PollAdd op; in epoll impl, it will use use inner readiness state; if !relaxed, it will call syscall poll after that.

If relaxed, on legacy driver it may return false positive result. If you want to do io by your own, you must maintain io readiness and wait for io ready with relaxed=false.

Source§

impl UnixStream

Source

pub fn try_into_poll_io(self) -> Result<UnixStreamPoll, (Error, UnixStream)>

Convert to poll-io style UnixStreamPoll

Trait Implementations§

Source§

impl AsRawFd for UnixStream

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl AsReadFd for UnixStream

Source§

fn as_reader_fd(&mut self) -> &SharedFdWrapper

Get fd.
Source§

impl AsWriteFd for UnixStream

Source§

fn as_writer_fd(&mut self) -> &SharedFdWrapper

Get fd.
Source§

impl AsyncReadRent for UnixStream

Source§

fn read<T: IoBufMut>( &mut self, buf: T, ) -> impl Future<Output = BufResult<usize, T>>

Reads bytes from this source into the provided buffer, returning the number of bytes read. Read more
Source§

fn readv<T: IoVecBufMut>( &mut self, buf: T, ) -> impl Future<Output = BufResult<usize, T>>

Similar to read, but reads data into a slice of buffers. Read more
Source§

impl AsyncWriteRent for UnixStream

Source§

fn write<T: IoBuf>( &mut self, buf: T, ) -> impl Future<Output = BufResult<usize, T>>

Writes the contents of a buffer into this writer, returning the number of bytes written. Read more
Source§

fn writev<T: IoVecBuf>( &mut self, buf_vec: T, ) -> impl Future<Output = BufResult<usize, T>>

This function attempts to write the entire contents of buf_vec, but the write may not fully succeed, and it might also result in an error. The bytes will be written starting at the specified offset. Read more
Source§

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

Flushes this output stream, ensuring that all buffered content is successfully written to its destination. Read more
Source§

fn shutdown(&mut self) -> impl Future<Output = Result<()>>

Shuts down the output stream, ensuring that the value can be cleanly dropped. Read more
Source§

impl CancelableAsyncReadRent for UnixStream

Source§

async fn cancelable_read<T: IoBufMut>( &mut self, buf: T, c: CancelHandle, ) -> BufResult<usize, T>

Same as read(2)
Source§

async fn cancelable_readv<T: IoVecBufMut>( &mut self, buf: T, c: CancelHandle, ) -> BufResult<usize, T>

Same as readv(2)
Source§

impl CancelableAsyncWriteRent for UnixStream

Source§

async fn cancelable_write<T: IoBuf>( &mut self, buf: T, c: CancelHandle, ) -> BufResult<usize, T>

Same as write(2)
Source§

async fn cancelable_writev<T: IoVecBuf>( &mut self, buf_vec: T, c: CancelHandle, ) -> BufResult<usize, T>

Same as writev(2)
Source§

async fn cancelable_flush(&mut self, _c: CancelHandle) -> Result<()>

Flush buffered data if needed
Source§

async fn cancelable_shutdown(&mut self, _c: CancelHandle) -> Result<()>

Same as shutdown
Source§

impl Debug for UnixStream

Source§

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

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

impl IntoPollIo for UnixStream

Source§

type PollIo = UnixStreamPoll

The poll-based io type.
Source§

fn try_into_poll_io(self) -> Result<Self::PollIo, (Error, Self)>

Convert a completion-based io to a poll-based io(able to get comp_io back).
Source§

fn into_poll_io(self) -> Result<Self::PollIo>

Convert a completion-based io to a poll-based io.
Source§

impl IntoRawFd for UnixStream

Source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. Read more
Source§

impl Split for UnixStream

UnixStream is safe to split to two parts

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<A> AsyncReadRentExt for A
where A: AsyncReadRent + ?Sized,

Source§

async fn read_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoBufMut + 'static,

Read until buf capacity is fulfilled
Source§

async fn read_vectored_exact<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoVecBufMut + 'static,

Readv until buf capacity is fulfilled
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

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

Read number in async way
Source§

impl<A> AsyncWriteRentExt for A
where A: AsyncWriteRent + ?Sized,

Source§

async fn write_all<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoBuf + 'static,

Write all
Source§

async fn write_vectored_all<T>(&mut self, buf: T) -> (Result<usize, Error>, T)
where T: IoVecBuf + 'static,

Write vectored all
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<A> CancelableAsyncReadRentExt for A

Source§

async fn cancelable_read_exact<T>( &mut self, buf: T, c: CancelHandle, ) -> (Result<usize, Error>, T)
where T: IoBufMut + 'static,

Read until buf capacity is fulfilled
Source§

async fn cancelable_read_vectored_exact<T>( &mut self, buf: T, c: CancelHandle, ) -> (Result<usize, Error>, T)
where T: IoVecBufMut + 'static,

Readv until buf capacity is fulfilled
Source§

async fn cancelable_read_u8(&mut self, c: CancelHandle) -> Result<u8, Error>

Read number in async way
Source§

async fn cancelable_read_u16(&mut self, c: CancelHandle) -> Result<u16, Error>

Read number in async way
Source§

async fn cancelable_read_u32(&mut self, c: CancelHandle) -> Result<u32, Error>

Read number in async way
Source§

async fn cancelable_read_u64(&mut self, c: CancelHandle) -> Result<u64, Error>

Read number in async way
Source§

async fn cancelable_read_u128(&mut self, c: CancelHandle) -> Result<u128, Error>

Read number in async way
Source§

async fn cancelable_read_i8(&mut self, c: CancelHandle) -> Result<i8, Error>

Read number in async way
Source§

async fn cancelable_read_i16(&mut self, c: CancelHandle) -> Result<i16, Error>

Read number in async way
Source§

async fn cancelable_read_i32(&mut self, c: CancelHandle) -> Result<i32, Error>

Read number in async way
Source§

async fn cancelable_read_i64(&mut self, c: CancelHandle) -> Result<i64, Error>

Read number in async way
Source§

async fn cancelable_read_i128(&mut self, c: CancelHandle) -> Result<i128, Error>

Read number in async way
Source§

async fn cancelable_read_f32(&mut self, c: CancelHandle) -> Result<f32, Error>

Read number in async way
Source§

async fn cancelable_read_f64(&mut self, c: CancelHandle) -> Result<f64, Error>

Read number in async way
Source§

async fn cancelable_read_u8_le(&mut self, c: CancelHandle) -> Result<u8, Error>

Read number in async way
Source§

async fn cancelable_read_u16_le( &mut self, c: CancelHandle, ) -> Result<u16, Error>

Read number in async way
Source§

async fn cancelable_read_u32_le( &mut self, c: CancelHandle, ) -> Result<u32, Error>

Read number in async way
Source§

async fn cancelable_read_u64_le( &mut self, c: CancelHandle, ) -> Result<u64, Error>

Read number in async way
Source§

async fn cancelable_read_u128_le( &mut self, c: CancelHandle, ) -> Result<u128, Error>

Read number in async way
Source§

async fn cancelable_read_i8_le(&mut self, c: CancelHandle) -> Result<i8, Error>

Read number in async way
Source§

async fn cancelable_read_i16_le( &mut self, c: CancelHandle, ) -> Result<i16, Error>

Read number in async way
Source§

async fn cancelable_read_i32_le( &mut self, c: CancelHandle, ) -> Result<i32, Error>

Read number in async way
Source§

async fn cancelable_read_i64_le( &mut self, c: CancelHandle, ) -> Result<i64, Error>

Read number in async way
Source§

async fn cancelable_read_i128_le( &mut self, c: CancelHandle, ) -> Result<i128, Error>

Read number in async way
Source§

async fn cancelable_read_f32_le( &mut self, c: CancelHandle, ) -> Result<f32, Error>

Read number in async way
Source§

async fn cancelable_read_f64_le( &mut self, c: CancelHandle, ) -> Result<f64, Error>

Read number in async way
Source§

impl<A> CancelableAsyncWriteRentExt for A

Source§

async fn write_all<T>( &mut self, buf: T, c: CancelHandle, ) -> (Result<usize, Error>, T)
where T: IoBuf + 'static,

Write all
Source§

async fn write_vectored_all<T>( &mut self, buf: T, c: CancelHandle, ) -> (Result<usize, Error>, T)
where T: IoVecBuf + 'static,

Write all
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> Splitable for T
where T: Split + AsyncWriteRent,

Source§

type OwnedRead = OwnedReadHalf<T>

Owned Read Split
Source§

type OwnedWrite = OwnedWriteHalf<T>

Owned Write Split
Source§

fn into_split( self, ) -> (<T as Splitable>::OwnedRead, <T as Splitable>::OwnedWrite)

Split into owned parts
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.