Skip to content

Commit

Permalink
Prepare 0.1.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
eldruin committed Jul 7, 2020
1 parent c7d733e commit 7d2c22d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 79 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.1.3] - 2020-07-07

This release of the 0.1 version exists for compatibility with 1.0.0.
There are no functional changes compared to 0.1.2.

## [v0.1.2] - 2019-04-21

### Added
Expand All @@ -26,6 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

Initial release

[Unreleased]: https://github.com/japaric/nb/compare/v0.1.2...HEAD
[v0.1.2]: https://github.com/japaric/nb/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/japaric/nb/compare/v0.1.0...v0.1.1
[Unreleased]: https://github.com/rust-embedded/nb/compare/v0.1.3...HEAD
[v0.1.3]: https://github.com/rust-embedded/nb/compare/v0.1.2...v0.1.3
[v0.1.2]: https://github.com/rust-embedded/nb/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/rust-embedded/nb/compare/v0.1.0...v0.1.1
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ description = "Minimal non-blocking I/O layer"
keywords = ["await", "futures", "IO"]
license = "MIT OR Apache-2.0"
name = "nb"
repository = "https://github.com/japaric/nb"
version = "0.1.2"
repository = "https://github.com/rust-embedded/nb"
homepage = "https://github.com/rust-embedded/nb"
documentation = "https://docs.rs/nb"
readme = "README.md"
version = "0.1.3" # remember to update html_root_url

[features]
unstable = []

[dependencies]
nb = "1"

[dev-dependencies]
futures = "0.1.17"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> Minimal and reusable non-blocking I/O layer
This project is developed and maintained by the [HAL team][team].

## [Documentation](https://docs.rs/nb)

## License
Expand All @@ -19,3 +21,5 @@ at your option.
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.

[team]: https://github.com/rust-embedded/wg#the-hal-team
78 changes: 4 additions & 74 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,52 +355,10 @@
//! ```
#![no_std]
#![doc(html_root_url = "https://docs.rs/nb/0.1.3")]

use core::fmt;

/// A non-blocking result
pub type Result<T, E> = ::core::result::Result<T, Error<E>>;

/// A non-blocking error
///
/// The main use of this enum is to add a `WouldBlock` variant to an existing
/// error enum.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Error<E> {
/// A different kind of error
Other(E),
/// This operation requires blocking behavior to complete
WouldBlock,
}

impl<E> fmt::Debug for Error<E>
where
E: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Other(ref e) => fmt::Debug::fmt(e, f),
Error::WouldBlock => f.write_str("WouldBlock"),
}
}
}

impl<E> Error<E> {
/// Maps an `Error<E>` to `Error<T>` by applying a function to a contained
/// `Error::Other` value, leaving an `Error::WouldBlock` value untouched.
pub fn map<T, F>(self, op: F) -> Error<T> where F: FnOnce(E) -> T {
match self {
Error::Other(e) => Error::Other(op(e)),
Error::WouldBlock => Error::WouldBlock,
}
}
}

impl<E> From<E> for Error<E> {
fn from(error: E) -> Error<E> {
Error::Other(error)
}
}
extern crate nb;
pub use nb::{block, Error, Result};

/// Await operation (*won't work until the language gains support for
/// generators*)
Expand Down Expand Up @@ -441,35 +399,7 @@ macro_rules! await {
}
}

/// Turns the non-blocking expression `$e` into a blocking operation.
///
/// This is accomplished by continuously calling the expression `$e` until it no
/// longer returns `Error::WouldBlock`
///
/// # Input
///
/// An expression `$e` that evaluates to `nb::Result<T, E>`
///
/// # Output
///
/// - `Ok(t)` if `$e` evaluates to `Ok(t)`
/// - `Err(e)` if `$e` evaluates to `Err(nb::Error::Other(e))`
#[macro_export]
macro_rules! block {
($e:expr) => {
loop {
#[allow(unreachable_patterns)]
match $e {
Err($crate::Error::Other(e)) => {
#[allow(unreachable_code)]
break Err(e)
},
Err($crate::Error::WouldBlock) => {},
Ok(x) => break Ok(x),
}
}
}
}


/// Future adapter
///
Expand Down

0 comments on commit 7d2c22d

Please sign in to comment.