Trait AsyncPollable

Source
pub trait AsyncPollable<T, E> {
    // Required method
    fn block(self) -> Result<T, E>;
}
Expand description

Helper methods for nullary closures returning crate::Result

Required Methods§

Source

fn block(self) -> Result<T, E>

Convenience method for crate::block

use std::fs::File;
use std::io;

use toad_async::{nb, AsyncPollable};

fn wait_for_file() -> nb::Result<File, io::Error> {
  match File::open("foo.txt") {
    | Ok(f) => Ok(f),
    | Err(e) if e.kind() == io::ErrorKind::NotFound => Err(nb::Error::WouldBlock),
    | Err(e) => Err(nb::Error::Other(e)),
  }
}

let f: io::Result<File> = wait_for_file.block();

Implementors§

Source§

impl<F, T, E> AsyncPollable<T, E> for F
where F: Fn() -> Result<T, E>,