Skip to content

Minimal and reusable non-blocking I/O layer

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rust-embedded/nb

crates.io crates.io Documentation Minimum Supported Rust Version

nb

Minimal and reusable non-blocking I/O layer

This project is developed and maintained by the HAL team.

The ultimate goal of this crate is code reuse. With this crate you can write core I/O APIs that can then be adapted to operate in either blocking or non-blocking manner. Furthermore those APIs are not tied to a particular asynchronous model and can be adapted to work with the futures model or with the async / await model.

Core idea

The WouldBlock error variant signals that the operation can't be completed right now and would need to block to complete. WouldBlock is a special error in the sense that it's not fatal; the operation can still be completed by retrying again later.

nb::Result is based on the API of std::io::Result, which has a WouldBlock variant in its ErrorKind.

We can map WouldBlock to different blocking and non-blocking models:

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.62 and up. It might compile with older versions but that may change in any new patch release.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Code of Conduct

Contribution to this crate is organized under the terms of the Rust Code of Conduct, the maintainer of this crate, the HAL team, promises to intervene to uphold that code of conduct.