Skip to main content

AsyncFd

Trait AsyncFd 

Source
pub trait AsyncFd<T: AsRawFd + AsFd + Send + Sync + 'static>:
    Send
    + Sync
    + 'static
    + Deref<Target = T> {
    // Required methods
    fn async_read<R>(
        &self,
        f: impl FnMut(&T) -> Result<R> + Send,
    ) -> impl Future<Output = Result<R>> + Send;
    fn async_write<R>(
        &self,
        f: impl FnMut(&T) -> Result<R> + Send,
    ) -> impl Future<Output = Result<R>> + Send;
}
Expand description

Trait for async file descriptor operations.

This trait provides methods for performing async read and write operations on file descriptors.

§Type Parameters

  • T - The underlying file descriptor type

Required Methods§

Source

fn async_read<R>( &self, f: impl FnMut(&T) -> Result<R> + Send, ) -> impl Future<Output = Result<R>> + Send

Perform an async read operation.

This method executes the provided closure asynchronously, allowing it to perform read operations on the underlying file descriptor.

§Parameters
  • f - A closure that performs the actual read operation
§Returns

A future that resolves to the result of the read operation.

Source

fn async_write<R>( &self, f: impl FnMut(&T) -> Result<R> + Send, ) -> impl Future<Output = Result<R>> + Send

Perform an async write operation.

This method executes the provided closure asynchronously, allowing it to perform write operations on the underlying file descriptor.

§Parameters
  • f - A closure that performs the actual write operation
§Returns

A future that resolves to the result of the write operation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§