2020-03-26 08:35:05 +08:00
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
extern crate alloc;
|
|
|
|
|
|
|
|
pub mod task;
|
|
|
|
pub mod executor;
|
2020-04-25 07:18:49 +08:00
|
|
|
mod delay;
|
|
|
|
pub use delay::delay;
|
2020-03-31 07:16:58 +08:00
|
|
|
|
|
|
|
pub mod smoltcp;
|
2020-04-25 07:18:49 +08:00
|
|
|
|
|
|
|
/// Reexport for macro use
|
|
|
|
pub use nb;
|
|
|
|
|
|
|
|
/// The `nb` crate's `block!` macro adapted for async fns
|
|
|
|
///
|
|
|
|
/// Call `.await` on the result!
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! block_async {
|
|
|
|
($e:expr) => {
|
|
|
|
async {
|
|
|
|
loop {
|
|
|
|
#[allow(unreachable_patterns)]
|
|
|
|
match $e {
|
|
|
|
Err($crate::nb::Error::Other(e)) => {
|
|
|
|
#[allow(unreachable_code)]
|
|
|
|
break Err(e)
|
|
|
|
},
|
|
|
|
Err($crate::nb::Error::WouldBlock) =>
|
|
|
|
$crate::task::r#yield().await,
|
|
|
|
Ok(x) => break Ok(x),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|