Skip to main content

poll_io

Function poll_io 

Source
pub async fn poll_io<P, F, T, E>(
    pollable: &P,
    events: IoEvents,
    non_blocking: bool,
    f: F,
) -> Result<T, E>
where P: Pollable, F: FnMut() -> Result<T, E>, E: PollIoError,
Expand description

A helper to wrap a synchronous non-blocking I/O function into an asynchronous function.

§Arguments

  • pollable: The pollable object to register for I/O events.
  • events: The I/O events to wait for.
  • non_blocking: If true, the function returns the caller’s would-block error immediately when the I/O operation would block.
  • f: The synchronous non-blocking I/O function to be wrapped. It should return an error recognized by PollIoError::is_would_block when the operation would block.