Skip to main content

AsyncFd

Struct AsyncFd 

Source
pub struct AsyncFd<T: AsFd> { /* private fields */ }
Expand description

A caller’s own descriptor, driven by readiness.

Implementations§

Source§

impl<T: AsFd> AsyncFd<T>

Source

pub fn new(inner: T) -> Result<Self>

Drives inner by readiness for reading and writing both.

§Errors

Never today: the descriptor registers with the shard that first waits on it, and a poller that refuses it (a regular file, on epoll) says so at that wait.

Source

pub fn with_interest(inner: T, interest: Interest) -> Result<Self>

Drives inner by readiness for what interest names.

§Errors

As new.

Source

pub fn get_ref(&self) -> &T

The descriptor.

Source

pub fn get_mut(&mut self) -> &mut T

The descriptor, to change.

Source

pub fn into_inner(self) -> T

The descriptor back, no longer watched.

Source

pub fn poll_read_ready<'a>( &'a self, cx: &mut Context<'_>, ) -> Poll<Result<AsyncFdReadyGuard<'a, T>>>

Polls until the descriptor may be readable.

§Errors

When the descriptor cannot be watched.

Source

pub fn poll_write_ready<'a>( &'a self, cx: &mut Context<'_>, ) -> Poll<Result<AsyncFdReadyGuard<'a, T>>>

Polls until the descriptor may be writable.

§Errors

When the descriptor cannot be watched.

Source

pub async fn readable(&self) -> Result<AsyncFdReadyGuard<'_, T>>

Waits until the descriptor may be readable.

§Errors

When the descriptor cannot be watched.

Source

pub async fn writable(&self) -> Result<AsyncFdReadyGuard<'_, T>>

Waits until the descriptor may be writable.

§Errors

When the descriptor cannot be watched.

Source

pub async fn ready( &self, interest: Interest, ) -> Result<AsyncFdReadyGuard<'_, T>>

Waits until some of interest may be ready.

§Errors

When the descriptor cannot be watched, and InvalidInput when it is not watched for any of interest.

Source

pub async fn readable_mut(&mut self) -> Result<AsyncFdReadyMutGuard<'_, T>>

As readable, with the descriptor borrowed mutably.

§Errors

When the descriptor cannot be watched.

Source

pub async fn writable_mut(&mut self) -> Result<AsyncFdReadyMutGuard<'_, T>>

As writable, with the descriptor borrowed mutably.

§Errors

When the descriptor cannot be watched.

Source

pub async fn ready_mut( &mut self, interest: Interest, ) -> Result<AsyncFdReadyMutGuard<'_, T>>

As ready, with the descriptor borrowed mutably.

§Errors

When the descriptor cannot be watched.

Source

pub async fn async_io<R>( &self, interest: Interest, f: impl FnMut(&T) -> Result<R>, ) -> Result<R>

Runs f on the descriptor each time some of interest may be ready, until it answers other than WouldBlock, clearing the readiness each time it does.

§Errors

What f answers, when the descriptor cannot be watched, and InvalidInput when it is not watched for any of interest.

Source

pub fn try_io<R>( &self, interest: Interest, f: impl FnOnce(&T) -> Result<R>, ) -> Result<R>

Runs f on the descriptor now if some of interest may be ready, clearing that readiness if it answers WouldBlock.

§Errors

WouldBlock when none of interest may be ready, InvalidInput when the descriptor is not watched for any of it, and what f answers.

Trait Implementations§

Source§

impl<T: AsFd + Debug> Debug for AsyncFd<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for AsyncFd<T>

§

impl<T> !RefUnwindSafe for AsyncFd<T>

§

impl<T> !UnwindSafe for AsyncFd<T>

§

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

§

impl<T> Sync for AsyncFd<T>
where T: Sync,

§

impl<T> Unpin for AsyncFd<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for AsyncFd<T>
where T: UnsafeUnpin,

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

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

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.