pub struct AsyncFd<T: AsFd> { /* private fields */ }Expand description
A caller’s own descriptor, driven by readiness.
Implementations§
Source§impl<T: AsFd> AsyncFd<T>
impl<T: AsFd> AsyncFd<T>
Sourcepub fn new(inner: T) -> Result<Self>
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.
Sourcepub fn with_interest(inner: T, interest: Interest) -> Result<Self>
pub fn with_interest(inner: T, interest: Interest) -> Result<Self>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
The descriptor back, no longer watched.
Sourcepub fn poll_read_ready<'a>(
&'a self,
cx: &mut Context<'_>,
) -> Poll<Result<AsyncFdReadyGuard<'a, T>>>
pub fn poll_read_ready<'a>( &'a self, cx: &mut Context<'_>, ) -> Poll<Result<AsyncFdReadyGuard<'a, T>>>
Sourcepub fn poll_write_ready<'a>(
&'a self,
cx: &mut Context<'_>,
) -> Poll<Result<AsyncFdReadyGuard<'a, T>>>
pub fn poll_write_ready<'a>( &'a self, cx: &mut Context<'_>, ) -> Poll<Result<AsyncFdReadyGuard<'a, T>>>
Sourcepub async fn readable(&self) -> Result<AsyncFdReadyGuard<'_, T>>
pub async fn readable(&self) -> Result<AsyncFdReadyGuard<'_, T>>
Sourcepub async fn writable(&self) -> Result<AsyncFdReadyGuard<'_, T>>
pub async fn writable(&self) -> Result<AsyncFdReadyGuard<'_, T>>
Sourcepub async fn ready(
&self,
interest: Interest,
) -> Result<AsyncFdReadyGuard<'_, T>>
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.
Sourcepub async fn readable_mut(&mut self) -> Result<AsyncFdReadyMutGuard<'_, T>>
pub async fn readable_mut(&mut self) -> Result<AsyncFdReadyMutGuard<'_, T>>
Sourcepub async fn writable_mut(&mut self) -> Result<AsyncFdReadyMutGuard<'_, T>>
pub async fn writable_mut(&mut self) -> Result<AsyncFdReadyMutGuard<'_, T>>
Sourcepub async fn ready_mut(
&mut self,
interest: Interest,
) -> Result<AsyncFdReadyMutGuard<'_, T>>
pub async fn ready_mut( &mut self, interest: Interest, ) -> Result<AsyncFdReadyMutGuard<'_, T>>
Sourcepub async fn async_io<R>(
&self,
interest: Interest,
f: impl FnMut(&T) -> Result<R>,
) -> Result<R>
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.
Sourcepub fn try_io<R>(
&self,
interest: Interest,
f: impl FnOnce(&T) -> Result<R>,
) -> Result<R>
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.